Greg Ercolano wrote:
> Alvin wrote:
>> Is there a method via the API that I can use to will prevent a Fl_Input
>> widget (Value_Input, etc.) from losing focus?
>>
>> I have a dialog box that contains a Fl_Input. The dialog box appears when
>> a button is pushed on the main window.
>>
>> I would like the text in the Fl_Input to be selected which I do using
>> position(0, size()) method.
>
> If you call textbox->take_focus() above or below that,
> it should do that.
>
>> However, when the Fl_Input loses focus, say I click on a blank part of
>> the dialog box, the selection highlight disappears. I would like to
>> prevent this.
>
> The question is what is it loosing focus too?
> Fl_Window and Fl_Double_Window don't, AFAIK, take 'focus',
> since they're not focus-oriented themselves.
>
> Focus should only move to other widgets if they accept focus.
> I would think ifother widgets did not accept focus (by returning 0
> to FL_FOCUS events) there wouldn't be a change in focus.
>
> I'm thinking there must be some other widget in your dialog,
> visible or not, that is accepting focus besides the Fl_Input.
>
> Perhaps you have button widgets in addition to the Fl_Input
> which are taking focus. Buttons are responsive to keyboard
> events (eg. using TAB and Shift-TAB or arrow keys to move
> focus around)
>
> If you make those buttons not take focus, then I suppose
> Fl_Input would retain focus.. but it would disable people
> from being able to use keyboard nav for your dialog.
> For instance if your own button derived widget returned 0
> to FL_FOCUS and FL_UNFOCUS events. There are probably other
> ways.
>
> The following code, for instance, should not loose focus
> to Fl_Input because there's no other focus-oriented widget
> that would accept it:
>
> #include <FL/Fl.H>
> #include <FL/Fl_Double_Window.H>
> #include <FL/Fl_Input.H>
> int main(int argc, char** argv) {
> Fl_Double_Window win(400,300,"Test");
> Fl_Input in(100,10,200,25,"Text");
> in.value("One two three");
> in.position(0, in.size());
> win.show();
> return(Fl::run());
> }
>
> This should show Fl_Double_Window is not taking focus.
Yeah, you are right. There must be something else going on. I tried to make
an example to post as a follow up. The example worked as expect. I think I
need to investigate this a little more.
--
Alvin
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk