From 99eeb17128a692e74bc1206c2c8fe5e8d9607bf1 Mon Sep 17 00:00:00 2001 From: Vedran Ljubovic Date: Wed, 30 Aug 2006 09:18:35 +0000 Subject: [PATCH] Some more fixes to rename box... now it works pretty well :) --- efiler/EDE_FileBrowser.cpp | 44 +++++++++++++++++++++----------------- efiler/EDE_FileBrowser.h | 4 ++-- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/efiler/EDE_FileBrowser.cpp b/efiler/EDE_FileBrowser.cpp index 1eded5d..7eea605 100644 --- a/efiler/EDE_FileBrowser.cpp +++ b/efiler/EDE_FileBrowser.cpp @@ -142,31 +142,31 @@ int EditBox::handle(int event) { } // Hide editbox - - // FIXME: Why is event_x() sometimes negative when we click inside box and sometimes not. Sometimes appears to be relative to window, sometimes to browser - - if (above || ( event==KEY && event_key()==EscapeKey ) || - // Click outside editbox: - ( event==PUSH && event_x()>0 && !event_inside(Rectangle(x()-parent()->x(),y()-parent()->y(),w(),h())) ) ) { -//fprintf (stderr, "Event: %d,%d Box: %d,%d,%d,%d\n",event_x(),event_y(),x(),y(),w(),h()); + if (above || ( event==KEY && event_key()==EscapeKey ) ) { this->hide(); - // Remove box so it doesn't get in the way - this->x(0); - this->y(0); - this->w(0); - this->h(0); - // Return the browser item into "visible" state - editing_->textcolor(textcolor()); - editing_->redraw(); - parent()->take_focus(); - // If user clicked outside box, this should select something else: - if (event==PUSH) return parent()->handle(event); return 1; } Input::handle(event); } +// We override hide method to ensure certain things done +void EditBox::hide() { + Input::hide(); + // Remove box so it doesn't get in the way + this->x(0); + this->y(0); + this->w(0); + this->h(0); + // Return the browser item into "visible" state + if (editing_) { + editing_->textcolor(textcolor()); + editing_->redraw(); + parent()->take_focus(); + } +} + + // Column widths and titles // TODO: make more configurable @@ -353,8 +353,12 @@ int FileBrowser::handle(int event) { const int iconspace=20; // Handle all events in editbox - if (editbox_->visible()) - return editbox_->handle(event); + if (editbox_->visible()) { + if (event == PUSH && !event_inside(Rectangle(editbox_->x(), editbox_->y(), editbox_->w(), editbox_->h()))) + editbox_->hide(); + else + return editbox_->handle(event); + } if (event==PUSH && !event_clicks() && // Don't accept clicks outside first column: diff --git a/efiler/EDE_FileBrowser.h b/efiler/EDE_FileBrowser.h index 41299ad..3f21efd 100644 --- a/efiler/EDE_FileBrowser.h +++ b/efiler/EDE_FileBrowser.h @@ -44,14 +44,14 @@ // FIXME: Why can this box be resized???? // TODO: When editbox appears, select filename part and leave extension not-selected // (as in Konqueror) -// FIXME: Clicking on letter in editbox doesn't move cursor to that letter class EditBox : public fltk::Input { fltk::Widget* editing_; public: - EditBox(int x, int y, int w, int h, const char* label = 0) : fltk::Input(x,y,w,h,label) {} + EditBox(int x, int y, int w, int h, const char* label = 0) : fltk::Input(x,y,w,h,label) , editing_(0) {} void editing(fltk::Widget*w) { editing_=w; } int handle (int event); + void hide(); };