Repos / mcross / ca08134381
commit ca08134381a8068fea24b17fccb1d5942cd36c1d
Author: Bùi Thành Nhân <hi@imnhan.com>
Date:   Thu May 28 18:32:10 2020 +0700

    ctrl-l to jump to address bar

diff --git a/src/mcross/gui/view.py b/src/mcross/gui/view.py
index 98ed551..33adee0 100644
--- a/src/mcross/gui/view.py
+++ b/src/mcross/gui/view.py
@@ -113,6 +113,12 @@ def __init__(self, root: Tk, model: Model):
         address_bar.bind("<KP_Enter>", self._on_go)
         address_bar.focus_set()
 
+        def on_ctrl_l(ev):
+            address_bar.focus()
+            address_bar.select_all()
+
+        root.bind("<Control-l>", on_ctrl_l)
+
         # Go button
         go_btn = ttk.Button(row1, text="三三ᕕ( ᐛ )ᕗ", command=self._on_go, width=10)
         self.go_btn = go_btn
diff --git a/src/mcross/gui/widgets.py b/src/mcross/gui/widgets.py
index e5d63b8..846bd54 100644
--- a/src/mcross/gui/widgets.py
+++ b/src/mcross/gui/widgets.py
@@ -28,9 +28,9 @@ class McEntry(ttk.Entry):
     def __init__(self, *args, **kwargs):
         super().__init__(*args, **kwargs)
 
-        self.bind("<Control-a>", self._on_ctrl_a)
+        self.bind("<Control-a>", self.select_all)
 
-    def _on_ctrl_a(self, ev):
+    def select_all(self, ev=None):
         self.select_range(0, "end")
         self.icursor("end")
         return "break"