我有一个自定义类,CustomButton它扩展了Fl_Button. 在我的屏幕上有一堆Fl_Input小CustomButton部件,我希望能够使用选项卡按键在它们之间导航。输入字段之间CustomButton的标签工作正常,但一旦获得焦点,我似乎无法离开它。
这是我的句柄功能
int CustomButton::handle ( int event )
{
int is_event_handled = 0;
switch (event)
{
case FL_KEYBOARD:
// If the keypress was enter, toggle the button on/off
if (Fl::event_key() == FL_Enter || Fl::event_key() == FL_KP_Enter)
{
// Do stuff...
}
is_event_handled = 1;
break;
case FL_FOCUS:
case FL_UNFOCUS:
// The default Fl_Button handling does not allow Focus/Unfocus
// for the button so mark the even as handled to skip the Fl_Button processing
is_event_handled = 1;
break;
default:
is_event_handled = 0;
break;
}
if ( is_event_handled == 1 ) return 1;
return Fl_Round_Button::handle ( event );
}
我正在使用 fltk 1.1.10。