Fix tab focus management.

[GB.GTK]
* BUG: Fix tab focus management.

[GB.GTK3]
* BUG: Fix tab focus management.
This commit is contained in:
gambas 2022-01-05 16:07:57 +01:00
parent 184af48c18
commit 79fbe6c0a8
4 changed files with 30 additions and 35 deletions

View file

@ -2638,9 +2638,6 @@ void gControl::setNoTabFocus(bool v)
return;
}
if (_no_tab_focus == v)
return;
_no_tab_focus = v;
}
@ -2652,6 +2649,11 @@ bool gControl::isNoTabFocus() const
return _no_tab_focus;
}
bool gControl::isNoTabFocusRec() const
{
return isNoTabFocus() || (parent() && parent()->isNoTabFocusRec());
}
#ifdef GTK3
void gControl::onEnterEvent()
{
@ -2861,50 +2863,41 @@ gControl *gControl::nextFocus()
gControl *ctrl;
gControl *next_ctrl;
//fprintf(stderr, "next: %s\n", name());
if (isContainer())
{
ctrl = ((gContainer *)this)->firstChild();
if (ctrl)
{
//fprintf(stderr, "==> %s\n", ctrl->name());
return ctrl;
}
}
ctrl = this;
if (ctrl->isContainer() && ((gContainer *)ctrl)->childCount())
return ((gContainer *)ctrl)->firstChild();
for(;;)
{
next_ctrl = ctrl->next();
if (next_ctrl)
return next_ctrl;
if (ctrl->isTopLevel())
return ctrl;
ctrl = ctrl->parent();
if (!ctrl)
return NULL;
/*if (!ctrl->parent())
return ctrl->nextFocus();*/
}
}
gControl *gControl::previousFocus()
{
gControl *ctrl = previous();
gControl *ctrl;
gControl *next_ctrl;
if (!ctrl)
ctrl = this;
if (ctrl->isContainer() && ((gContainer *)ctrl)->childCount())
return ((gContainer *)ctrl)->lastChild();
for(;;)
{
if (!isTopLevel())
return parent()->previousFocus();
ctrl = this;
next_ctrl = ctrl->previous();
if (next_ctrl)
return next_ctrl;
if (ctrl->isTopLevel())
return ctrl;
ctrl = ctrl->parent();
}
while (ctrl->isContainer() && ((gContainer *)ctrl)->childCount())
ctrl = ((gContainer *)ctrl)->lastChild();
return ctrl;
}
void gControl::createWidget()

View file

@ -133,6 +133,7 @@ public:
void setTracking(bool vl);
bool isNoTabFocus() const;
bool isNoTabFocusRec() const;
void setNoTabFocus(bool v);
gColor background() const { return _bg; }

View file

@ -474,7 +474,6 @@ void gMainWindow::initWindow()
have_cursor = true; //parent() == 0 && !_xembed;
setCanFocus(true);
setNoTabFocus(true);
}

View file

@ -98,13 +98,15 @@ gboolean gcb_focus(GtkWidget *widget, GtkDirectionType direction, gControl *data
if (!ctrl)
break;
if (ctrl->isReallyVisible() && ctrl->isEnabled() && ctrl->canFocus() && !ctrl->isNoTabFocus())
//fprintf(stderr, "gcb_focus: %s / %d %d %d %d\n", ctrl->name(), ctrl->isReallyVisible(), ctrl->isEnabled(), ctrl->canFocus(), !ctrl->isNoTabFocusRec());
if (!ctrl->isTopLevel() && ctrl->isReallyVisible() && ctrl->isEnabled() && ctrl->canFocus() && !ctrl->isNoTabFocusRec())
{
//fprintf(stderr, "cb_focus: --> %s\n", ctrl->name());
//fprintf(stderr, "cb_focus: --> %s / %d\n", ctrl->name(), ctrl->isNoTabFocusRec());
ctrl->setFocus();
break;
}
if (ctrl == data)
if (ctrl == gApplication::activeControl())
break;
}
}