aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2006-11-12 02:22:21 -0500
committerShawn O. Pearce <spearce@spearce.org>2006-11-12 02:22:21 -0500
commit16fccd7a1111c1fca6ce973ddaff690188e742d0 (patch)
tree0960e88210ab8da4f3630119fc3813907f9b4b9b
parentb4946930fa0f7aa538e33f1d799beffb7e10e7a9 (diff)
downloadgit-16fccd7a1111c1fca6ce973ddaff690188e742d0.tar.gz
git-16fccd7a1111c1fca6ce973ddaff690188e742d0.tar.xz
git-gui: Improve right click context menu binding on all platforms.
Apparently <Button-3> doesn't work on my single button PowerBook mouse under Mac OS X. I'm guessing this is because Tk is stealing every event and doesn't realize that Control-Button-1 is actually supposed to invoke the context menu on this platform. So now we have a utility procedure is_MacOSX to guess if we are running on a Mac OS X system, and if so setup Control-Button-1 to also activate what Button-3 should have. This does mean that I need to stay away from using Control-Button-1 as a binding in any other context. Of course we should use $M1B for that, which is M1 (aka Command) on Mac OS X so that shouldn't prove to be a problem. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
-rwxr-xr-xgit-gui37
1 files changed, 29 insertions, 8 deletions
diff --git a/git-gui b/git-gui
index 3cbe3e7f7..040581e82 100755
--- a/git-gui
+++ b/git-gui
@@ -1285,6 +1285,23 @@ unset filemask i
##
## util
+proc is_MacOSX {} {
+ global tcl_platform tk_library
+ if {$tcl_platform(platform) == {unix}
+ && $tcl_platform(os) == {Darwin}
+ && [string match /Library/Frameworks/* $tk_library]} {
+ return 1
+ }
+ return 0
+}
+
+proc bind_button3 {w cmd} {
+ bind $w <Any-Button-3> $cmd
+ if {[is_MacOSX]} {
+ bind $w <Control-Button-1> $cmd
+ }
+}
+
proc incr_font_size {font {amt 1}} {
set sz [font configure $font -size]
incr sz $amt
@@ -1398,7 +1415,7 @@ proc console_init {w} {
-command "destroy $w"
pack $w.ok -side bottom
- bind $w.m.t <Any-Button-3> "tk_popup $w.ctxm %X %Y"
+ bind_button3 $w.m.t "tk_popup $w.ctxm %X %Y"
bind $w.m.t <$M1B-Key-a> "$w.m.t tag add sel 0.0 end;break"
bind $w.m.t <$M1B-Key-A> "$w.m.t tag add sel 0.0 end;break"
bind $w <Visibility> "focus $w"
@@ -1655,10 +1672,14 @@ font configure font_uibold -weight bold
eval font create font_diffbold [font configure font_diff]
font configure font_diffbold -weight bold
-switch -glob -- "$tcl_platform(platform),$tcl_platform(os)" {
-windows,* {set M1B Control; set M1T Ctrl}
-unix,Darwin {set M1B M1; set M1T Cmd}
-* {set M1B M1; set M1T M1}
+set M1B M1
+set M1T M1
+if {$tcl_platform(platform) == {windows}} {
+ set M1B Control
+ set M1T Ctrl
+} elseif {[is_MacOSX]} {
+ set M1B M1
+ set M1T Cmd
}
# -- Menu Bar
@@ -1920,7 +1941,7 @@ $ui_comm.ctxm add separator
$ui_comm.ctxm add command -label "Sign Off" \
-font font_ui \
-command do_signoff
-bind $ui_comm <Any-Button-3> "tk_popup $ui_comm.ctxm %X %Y"
+bind_button3 $ui_comm "tk_popup $ui_comm.ctxm %X %Y"
# -- Diff Header
set ui_fname_value {}
@@ -1997,7 +2018,7 @@ $ui_diff.ctxm add command -label "Decrease Font Size" \
$ui_diff.ctxm add command -label "Increase Font Size" \
-font font_ui \
-command {incr_font_size font_diff 1}
-bind $ui_diff <Any-Button-3> "tk_popup $ui_diff.ctxm %X %Y"
+bind_button3 $ui_diff "tk_popup $ui_diff.ctxm %X %Y"
# -- Status Bar
set ui_status_value {Initializing...}
@@ -2063,8 +2084,8 @@ bind all <$M1B-Key-w> {destroy [winfo toplevel %W]}
bind all <$M1B-Key-W> {destroy [winfo toplevel %W]}
foreach i [list $ui_index $ui_other] {
bind $i <Button-1> {click %W %x %y 1 %X %Y; break}
- bind $i <Button-3> {click %W %x %y 3 %X %Y; break}
bind $i <ButtonRelease-1> {unclick %W %x %y; break}
+ bind_button3 $i {click %W %x %y 3 %X %Y; break}
}
unset i