mirror of
https://github.com/fltk/fltk.git
synced 2026-05-24 16:36:37 +08:00
Fix "Keyboard sometimes stops working after Ctrl/+ or Ctrl/-" (#794)
This commit is contained in:
@@ -943,6 +943,10 @@ Fl_Widget* fl_oldfocus; // kludge for Fl_Group...
|
||||
/**
|
||||
Sets the widget that will receive FL_KEYBOARD events.
|
||||
|
||||
Use this function inside the \c handle(int) member function of a widget of yours
|
||||
to give focus to the widget, for example when it receives the FL_FOCUS or the FL_PUSH event.
|
||||
Otherwise, use Fl_Widget::take_focus() to give focus to a widget;
|
||||
|
||||
If you change Fl::focus(), the previous widget and all
|
||||
parents (that don't contain the new widget) are sent FL_UNFOCUS
|
||||
events. Changing the focus does \e not send FL_FOCUS to
|
||||
|
||||
@@ -393,8 +393,7 @@ static void del_transient_window(WinAndTracker *data) {
|
||||
Fl::delete_widget(data->win);
|
||||
if (data->tracker) {
|
||||
if (data->tracker->exists()) {
|
||||
Fl::focus(data->tracker->widget());
|
||||
data->tracker->widget()->handle(FL_FOCUS);
|
||||
data->tracker->widget()->take_focus();
|
||||
}
|
||||
delete data->tracker;
|
||||
}
|
||||
@@ -439,18 +438,12 @@ void Fl_Screen_Driver::transient_scale_display(float f, int nscreen)
|
||||
win->user_data((void*)&transient_scale_display); // prevent this window from being rescaled later
|
||||
win->set_output();
|
||||
win->set_non_modal();
|
||||
Fl_Window_Driver::driver(win)->screen_num(nscreen);
|
||||
Fl_Window_Driver::driver(win)->force_position(1);
|
||||
WinAndTracker *data = new WinAndTracker;
|
||||
data->win = win;
|
||||
Fl_Widget *widget = Fl::focus();
|
||||
data->tracker = (widget ? new Fl_Widget_Tracker(widget) : NULL);
|
||||
if (widget) { // make transient a centered child of focussed window
|
||||
Fl_Window *top = widget->top_window();
|
||||
win->position((top->w() - win->w()) / 2, (top->h() - win->h()) / 2);
|
||||
top->add(win);
|
||||
} else { // center transient on display
|
||||
Fl_Window_Driver::driver(win)->screen_num(nscreen);
|
||||
Fl_Window_Driver::driver(win)->force_position(1);
|
||||
}
|
||||
win->show();
|
||||
Fl::add_timeout(1, (Fl_Timeout_Handler)del_transient_window, data); // delete after 1 sec
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user