[gnote/tabbed: 14/19] Fix focusing note editor




commit ffee9b8194da04e72b0d774d689350851559a00b
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Sun Oct 24 17:52:43 2021 +0300

    Fix focusing note editor

 src/notewindow.cpp    | 7 +++++--
 src/notewindow.hpp    | 1 +
 src/recentchanges.cpp | 5 ++++-
 3 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/src/notewindow.cpp b/src/notewindow.cpp
index f2b8c6bf..b2a0ab6c 100644
--- a/src/notewindow.cpp
+++ b/src/notewindow.cpp
@@ -104,8 +104,6 @@ namespace gnote {
     m_editor_window->set_vexpand(true);
     m_editor_window->show();
 
-    set_focus_child(*m_editor);
-
     attach(*m_template_widget, 0, 0, 1, 1);
     attach(*m_editor_window, 0, 1, 1, 1);
   }
@@ -193,6 +191,11 @@ namespace gnote {
     m_editor->scroll_to(m_editor->get_buffer()->get_insert());
   }
 
+  void NoteWindow::set_initial_focus()
+  {
+    m_editor->grab_focus();
+  }
+
   void NoteWindow::add_accel_group(Gtk::Window & window)
   {
     if(!m_accel_group) {
diff --git a/src/notewindow.hpp b/src/notewindow.hpp
index bd63ca74..2998436b 100644
--- a/src/notewindow.hpp
+++ b/src/notewindow.hpp
@@ -178,6 +178,7 @@ public:
     {
       return m_enabled;
     }
+  virtual void set_initial_focus() override;
 private:
   static Glib::RefPtr<Gio::Icon> get_icon_pin_active(IconManager & icon_manager);
   static Glib::RefPtr<Gio::Icon> get_icon_pin_down(IconManager & icon_manager);
diff --git a/src/recentchanges.cpp b/src/recentchanges.cpp
index 0061eda8..ed3d7b6a 100644
--- a/src/recentchanges.cpp
+++ b/src/recentchanges.cpp
@@ -436,9 +436,12 @@ namespace gnote {
         win->host()->unembed_widget(*win);
       }
       embed_widget(*win);
+      win->set_initial_focus();
     }
     else {
-      embed_widget(*note->create_window());
+      auto win = note->create_window();
+      embed_widget(*win);
+      win->set_initial_focus();
     }
   }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]