Thread (15 messages) flat view 15 messages, 3 authors, 2016-06-15
STALE3733d

[Gitk PATCH 1/6] gitk: Add procedure to create accelerated menus

From: Robin Rosenberg <hidden>
Date: 2016-06-15 22:45:27
Subsystem: the rest · Maintainer: Linus Torvalds

These are the undescores menu items that can be selected with the Alt+letter,
key combination on Windows and Linux or Command+letter on Macs.

Signed-off-by: Robin Rosenberg <redacted>
---
 gitk |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/gitk b/gitk
index 2eaa2ae..050019c 100755
--- a/gitk
+++ b/gitk
@@ -1750,6 +1750,33 @@ proc setoptions {} {
     option add *Entry.font uifont startupFile
 }
 
+# Menu command wrapper. Intercepts any -label arguments, 
+# removes the & and adds the -underline argument necessary
+# to implement the menu accelerator.
+proc mcw {menubar args} {
+    set ai [lsearch $args "-label"]
+    if { $ai > 0 } {
+	set label [lindex $args [expr {$ai + 1}]]
+	foreach {l u} [::tk::UnderlineAmpersand $label] {
+	    lset args [expr {$ai + 1}] $l
+	}
+	lappend args -underline
+	lappend args $u
+    }
+    set cmd [ list $menubar ]
+    foreach a $args {
+	lappend cmd $a
+    }
+    eval $cmd
+}
+
+# Wrapper for mc to remove ampersands used for accelerators.
+proc mca {label} {
+    set tl8 [mc $label]
+    foreach {l u} [::tk::UnderlineAmpersand $tl8] break
+    return $l
+}
+
 proc makewindow {} {
     global canv canv2 canv3 linespc charspc ctext cflist cscroll
     global tabstop
-- 
1.6.0.2.308.gef4a
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help