FLTK logo

Can't set focus on child widget in Fl_Tabs

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.general  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Can't set focus on child widget in Fl_Tabs William Knight May 21, 2006  
 
I've created a tabbed dialog using fluid and I want to set the focus on an Fl_Input widget when the dialog is shown. But the focus is always set to the 'Ok' button instead.

--------- Here's my layout in fluid:

Prefs_Dlg()
+Double_Window win
 +Tabs tabs
  +Group tab0
   +Input inp
  +Group tab1
   +Check_Button chk
 +Button "&Ok"
 +Button "&Cancel"

---------- Fluid-generated header:

class App_Prefs_Dlg {
public:
  App_Prefs_Dlg();
  Fl_Double_Window *win;
  Fl_Tabs *tabs;
  Fl_Group *tab0;
  Fl_Input *inp;
  Fl_Group *tab1;
  Fl_Check_Button *chk;
private:
  void cb_Ok_i(Fl_Button*, void*);
  static void cb_Ok(Fl_Button*, void*);
  void cb_Cancel_i(Fl_Button*, void*);
  static void cb_Cancel(Fl_Button*, void*);
};

---------- code to show dialog:

Prefs_Dlg *dlg = new Prefs_Dlg()
dlg->win->set_modal();
dlg->win->show();
dlg->inp->take_focus();
dlg->inp->position( strlen( inp->value()), 0 );

-----------

Observed Result: 'Ok' button has the focus
Expected Result:  inp widget has the focus, text is selected

What's the best way get the input widget to have the focus when the dialog is first shown? I'm currently using fltk-1.1.x-r4509.



Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.