diff --git a/src/ui/dialog/dialog-base.cpp b/src/ui/dialog/dialog-base.cpp index 14ef28b08434547673e1c3d1667a18f0dae178f8..52a5b44d4730f6acec90cef473eeea82ed1cca11 100644 --- a/src/ui/dialog/dialog-base.cpp +++ b/src/ui/dialog/dialog-base.cpp @@ -122,10 +122,10 @@ void DialogBase::blink() } void DialogBase::focus_dialog() { + set_visible(true); if (auto window = dynamic_cast(get_root())) { window->present(); } - // widget that had focus, if any if (auto child = get_focus_child()) { child->grab_focus(); @@ -135,6 +135,7 @@ void DialogBase::focus_dialog() { child->grab_focus(); } } + } void DialogBase::defocus_dialog() { diff --git a/src/ui/dialog/dialog-base.h b/src/ui/dialog/dialog-base.h index dc1d025800c3532d5448b5bf6dd62ff37cf5b1b0..496c84d4b2a04d525c4b95d6093977c9bcc51f0e 100644 --- a/src/ui/dialog/dialog-base.h +++ b/src/ui/dialog/dialog-base.h @@ -68,7 +68,7 @@ public: void blink(); // find focusable widget to grab focus - void focus_dialog(); + virtual void focus_dialog(); // return focus back to canvas void defocus_dialog(); bool getShowing() { return _showing; } diff --git a/src/ui/dialog/dialog-notebook.cpp b/src/ui/dialog/dialog-notebook.cpp index eaeb985eaf736c11b4e6151797049a4fed549403..f4467c78de2f62652648dc64b38bd20688fa3683 100644 --- a/src/ui/dialog/dialog-notebook.cpp +++ b/src/ui/dialog/dialog-notebook.cpp @@ -137,7 +137,12 @@ DialogNotebook::DialogNotebook(DialogContainer* container) : _container(containe _tabs.set_new_tab_popup(&_menu_dialogs); _tabs.signal_select_tab().connect([this](auto& tab) { _tabs.select_tab(tab); - _notebook.set_current_page(_tabs.get_tab_position(tab)); + int page_pos = _tabs.get_tab_position(tab); + _notebook.set_current_page(page_pos); + auto curr_page = _notebook.get_nth_page(page_pos); + if (auto dialog = dynamic_cast(curr_page)) { + dialog->focus_dialog(); + } }); _tabs.signal_close_tab().connect([this](auto& tab) { auto index = _tabs.get_tab_position(tab); @@ -663,6 +668,9 @@ void DialogNotebook::on_size_allocate_scroll(int const width) void DialogNotebook::on_page_switch(Gtk::Widget *curr_page, guint page) { _tabs.select_tab_at(page); + if (auto dialog = dynamic_cast(curr_page)) { + dialog->focus_dialog(); + } } bool DialogNotebook::on_scroll_event(double dx, double dy) diff --git a/src/ui/dialog/extensions-gallery.cpp b/src/ui/dialog/extensions-gallery.cpp index efba3be9488e69f765202548d72bdefac8001b72..abbc5ec6094f624f469e9c52c477946895d01410 100644 --- a/src/ui/dialog/extensions-gallery.cpp +++ b/src/ui/dialog/extensions-gallery.cpp @@ -466,6 +466,7 @@ ExtensionsGallery::ExtensionsGallery(ExtensionsGallery::Type type) : }); append(get_widget(_builder, "main")); + focus_dialog(); } void ExtensionsGallery::update_name() { @@ -581,5 +582,10 @@ Glib::RefPtr ExtensionsGallery::get_image(const std::string& key, return tex; } } +void ExtensionsGallery::focus_dialog() +{ + DialogBase::focus_dialog(); + _search.grab_focus(); +} } // namespace Inkscape::UI::Dialog diff --git a/src/ui/dialog/extensions-gallery.h b/src/ui/dialog/extensions-gallery.h index 5e41ff3371744fa155e65ef871f09d54d955edd4..548585527c2f388c24da9c338a399c4039bf632c 100644 --- a/src/ui/dialog/extensions-gallery.h +++ b/src/ui/dialog/extensions-gallery.h @@ -55,7 +55,7 @@ class ExtensionsGallery : public DialogBase public: enum Type { Filters, Effects }; ExtensionsGallery(Type type); - + void focus_dialog() override; private: Glib::RefPtr _builder; Gtk::GridView& _gridview; diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp index 70c58e55a65260c27a92cc0458f7def238c8425a..cb0ca199e67774b48f7c13881a3958b642336794 100644 --- a/src/ui/dialog/livepatheffect-editor.cpp +++ b/src/ui/dialog/livepatheffect-editor.cpp @@ -1130,6 +1130,12 @@ void LivePathEffectEditor::do_item_action_favorite(PathEffectSharedPtr const &, _reload_menu = true; _item_type = ""; // here we force reload even with the same tipe item selected } +void LivePathEffectEditor::focus_dialog() +{ + DialogBase::focus_dialog(); + _lpes_popup.get_entry().grab_focus(); + _lpes_popup.get_entry().queue_draw(); // force redraw to fix delay in hover style +} } // namespace Inkscape::UI::Dialog diff --git a/src/ui/dialog/livepatheffect-editor.h b/src/ui/dialog/livepatheffect-editor.h index 234e3b04c339eadc634ac61124a783b5f664cb9a..228ac93b7cd37f250afa74a9b71c32936d69d1cf 100644 --- a/src/ui/dialog/livepatheffect-editor.h +++ b/src/ui/dialog/livepatheffect-editor.h @@ -61,7 +61,7 @@ class LivePathEffectEditor final : public DialogBase public: LivePathEffectEditor(); ~LivePathEffectEditor() final; - + void focus_dialog() override; void move_list(int origin, int dest); using LPEExpander = std::pair;