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

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

 



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 <robin.rosenberg@xxxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux