Commit 47208e1d authored by gambas's avatar gambas
Browse files

Fix focus management when a control is hidden.

[GB.GTK]
* BUG: Fix focus management when a control is hidden.

[GB.GTK3]
* BUG: Fix focus management when a control is hidden.
parent f75b23a8
Pipeline #459261609 passed with stage
in 21 minutes and 12 seconds
......@@ -342,7 +342,7 @@ static void gambas_handle_event(GdkEvent *event)
//if (GTK_IS_WINDOW(widget))
{
control = gt_get_control(widget);
//control = gt_get_control(widget);
if (control)
gApplication::setActiveControl(control, event->focus_change.in);
else if (event->focus_change.in)
......@@ -1383,9 +1383,12 @@ void gApplication::setActiveControl(gControl *control, bool on)
return;
#if DEBUG_FOCUS
fprintf(stderr, "setActiveControl: %s %d / %d\n", control->name(), on, _focus_change);
fprintf(stderr, "setActiveControl: %s %s %d / %d\n", GB.GetClassName(control->hFree), control->name(), on, _focus_change);
#endif
/*if (!::strcmp(GB.GetClassName(control->hFree), "FEditor") && !on)
BREAKPOINT();*/
if (_active_control && !_focus_change)
_previous_control = _active_control;
......
......@@ -543,9 +543,12 @@ void gControl::setVisibility(bool vl)
}
else
{
if (parent() && hasFocus())
gcb_focus(widget, GTK_DIR_TAB_FORWARD, this);
gApplication::setActiveControl(this, false);
if (hasFocus())
{
if (parent())
gcb_focus(widget, GTK_DIR_TAB_FORWARD, this);
gApplication::setActiveControl(this, false);
}
if (gtk_widget_has_grab(border))
gtk_grab_remove(border);
gtk_widget_hide(border);
......@@ -694,9 +697,6 @@ void gControl::move(int x, int y)
updateGeometry();
#endif
/*if (name() && !::strcmp(name(), "txtTagEditor") && y == 43)
BREAKPOINT();*/
checkVisibility();
send_configure(this); // needed for Watcher and Form Move events
......@@ -1342,18 +1342,16 @@ void gControl::setFocus()
if (win->isVisible())
{
//if (isVisible() && bufW > 0 && bufH > 0)
#if DEBUG_FOCUS
fprintf(stderr, "setFocus now %s %p\n", name(), widget);
fprintf(stderr, "setFocus NOW: %s %s %p\n", GB.GetClassName(hFree), name(), hFree);
#endif
//win->activate();
gtk_widget_grab_focus(widget);
}
else
{
#if DEBUG_FOCUS
fprintf(stderr, "setFocus later %s\n", name());
fprintf(stderr, "setFocus later: %s %s %p\n", GB.GetClassName(hFree), name(), hFree);
#endif
win->_initial_focus = this;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment