On 16.12.2010 18:35, Greg Ercolano wrote:
> Greg Ercolano wrote:
>> I see it; this patch (below) removes the offending code.
>
>
> Albrecht; if that patch looks OK to you, I'd like to check it in.
I don't know...
> The code I'm removing in the patch makes no sense at all
> given the current behavior of the widget.
Your patch would actually invert the change that has been done in
svn r1517 (!) in August 2001 (FLTK 1.1.0). Unfortunately there's
no rationale given for this change. The log reads:
"FileIcon, FileBrowser, FileChooser stuff."
No mention of Fl_Input :-(
> This actually sounds familiar; I seem to remember a time when hitting
> 'tab' to move off the widget would instead delete the selected text,
> replacing it with a tab. This code appears to be a hack to fix that.
I also remember that you could sometimes add a TAB (shown as ^I) in an
Fl_Input widget, but I don't remember when this was.
And what happens if you apply your patch? Any side effects?
> But these days Tab is handled elsewhere in the code, punting the
> event back up to the parent.
I can't tell exactly what is correct or not, but I can definitely say
that I also think that this behavior is annoying (my users complained).
I fixed it in my app by resetting the selection in the handle() method
of my derived class like this:
if (key==FL_Tab && mark()!=position())
position(position()); // reset selection
return Fl_Input::handle(event);
We should probably also do this before we call handle_key(), hence a
/maybe/ better patch might look like this (just to make sure that the
selection isn't used in handle_key()):
Index: src/Fl_Input.cxx
===================================================================
--- src/Fl_Input.cxx (revision 8046)
+++ src/Fl_Input.cxx (working copy)
@@ -526,18 +526,11 @@
break;
case FL_KEYBOARD:
- if (Fl::event_key() == FL_Tab && mark() != position()) {
- // Set the current cursor position to the end of the selection...
- if (mark() > position())
- position(mark());
- else
- position(position());
- return (1);
- } else {
- if (active_r() && window() && this == Fl::belowmouse())
- window()->cursor(FL_CURSOR_NONE);
- return handle_key();
- }
+ if (Fl::event_key() == FL_Tab && mark() != position() /*1*/ )
+ position(position()); // reset the current selection...
+ if (active_r() && window() && this == Fl::belowmouse())
+ window()->cursor(FL_CURSOR_NONE);
+ return handle_key();
//NOTREACHED
case FL_PUSH:
----
/But/: this should probably also take into account that Tab can
be a legal character in Fl_Multiline_Input, and thus it *should*
replace the selection, shouldn't it? Unless it is used for
navigation...
/*1*/ add here: "&& input_type()!=FL_MULTILINE_INPUT /*2*/" (?)
/*2*/ ... && !Fl::option(WHATEVER_MULTILINE_USE_TAB_FOR_NAVIGATION)
Or maybe something completely different, I don't know...
Albrecht
_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev