enable grabbing focus to an unspecified container child
Change-Id: I269f76a3e71832ef2e8961952d9362838bd49cfc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112577 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
parent
486f329b95
commit
5aef0085ca
4 changed files with 42 additions and 4 deletions
|
@ -346,6 +346,8 @@ public:
|
|||
{
|
||||
m_aContainerFocusChangedHdl = rLink;
|
||||
}
|
||||
// causes a child of the container to have the keyboard focus
|
||||
virtual void child_grab_focus() = 0;
|
||||
};
|
||||
|
||||
class VCL_DLLPUBLIC Box : virtual public Container
|
||||
|
|
|
@ -419,6 +419,7 @@ public:
|
|||
bool bTakeOwnership);
|
||||
virtual void HandleEventListener(VclWindowEvent& rEvent) override;
|
||||
virtual void connect_container_focus_changed(const Link<Container&, void>& rLink) override;
|
||||
virtual void child_grab_focus() override;
|
||||
virtual void move(weld::Widget* pWidget, weld::Container* pNewParent) override;
|
||||
virtual void recursively_unset_default_buttons() override;
|
||||
virtual css::uno::Reference<css::awt::XWindow> CreateChildFrame() override;
|
||||
|
|
|
@ -1189,6 +1189,15 @@ void SalInstanceContainer::move(weld::Widget* pWidget, weld::Container* pNewPare
|
|||
pVclWidget->getWidget()->SetParentToDefaultWindow();
|
||||
}
|
||||
|
||||
void SalInstanceContainer::child_grab_focus()
|
||||
{
|
||||
disable_notify_events();
|
||||
m_xContainer->GrabFocus();
|
||||
if (vcl::Window* pFirstChild = m_xContainer->ImplGetDlgWindow(0, GetDlgWindowType::First))
|
||||
pFirstChild->ImplControlFocus();
|
||||
enable_notify_events();
|
||||
}
|
||||
|
||||
void SalInstanceContainer::recursively_unset_default_buttons()
|
||||
{
|
||||
implResetDefault(m_xContainer.get());
|
||||
|
|
|
@ -3817,6 +3817,27 @@ public:
|
|||
|
||||
GtkContainer* getContainer() { return m_pContainer; }
|
||||
|
||||
virtual void child_grab_focus() override
|
||||
{
|
||||
disable_notify_events();
|
||||
gtk_widget_grab_focus(m_pWidget);
|
||||
bool bHasFocusChild = gtk_container_get_focus_child(m_pContainer);
|
||||
if (!bHasFocusChild)
|
||||
{
|
||||
GList* pChildren = gtk_container_get_children(m_pContainer);
|
||||
for (GList* pChild = g_list_first(pChildren); pChild; pChild = g_list_next(pChild))
|
||||
{
|
||||
gtk_container_set_focus_child(m_pContainer, static_cast<GtkWidget*>(pChild->data));
|
||||
bHasFocusChild = true;
|
||||
break;
|
||||
}
|
||||
g_list_free(pChildren);
|
||||
}
|
||||
if (bHasFocusChild)
|
||||
gtk_widget_child_focus(gtk_container_get_focus_child(GTK_CONTAINER(m_pWidget)), GTK_DIR_TAB_FORWARD);
|
||||
enable_notify_events();
|
||||
}
|
||||
|
||||
virtual void move(weld::Widget* pWidget, weld::Container* pNewParent) override
|
||||
{
|
||||
GtkInstanceWidget* pGtkWidget = dynamic_cast<GtkInstanceWidget*>(pWidget);
|
||||
|
@ -8897,12 +8918,17 @@ public:
|
|||
{
|
||||
disable_notify_events();
|
||||
gtk_widget_grab_focus(m_pWidget);
|
||||
if (!gtk_container_get_focus_child(GTK_CONTAINER(m_pWidget)))
|
||||
bool bHasFocusChild = gtk_container_get_focus_child(GTK_CONTAINER(m_pWidget));
|
||||
if (!bHasFocusChild)
|
||||
{
|
||||
GtkToolItem* pItem = gtk_toolbar_get_nth_item(m_pToolbar, 0);
|
||||
gtk_container_set_focus_child(GTK_CONTAINER(m_pWidget), GTK_WIDGET(pItem));
|
||||
if (GtkToolItem* pItem = gtk_toolbar_get_nth_item(m_pToolbar, 0))
|
||||
{
|
||||
gtk_container_set_focus_child(GTK_CONTAINER(m_pWidget), GTK_WIDGET(pItem));
|
||||
bHasFocusChild = true;
|
||||
}
|
||||
}
|
||||
gtk_widget_child_focus(gtk_container_get_focus_child(GTK_CONTAINER(m_pWidget)), GTK_DIR_TAB_FORWARD);
|
||||
if (bHasFocusChild)
|
||||
gtk_widget_child_focus(gtk_container_get_focus_child(GTK_CONTAINER(m_pWidget)), GTK_DIR_TAB_FORWARD);
|
||||
enable_notify_events();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue