summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b494693)
raw | patch | inline | side by side (parent: b494693)
author | Shawn O. Pearce <spearce@spearce.org> | |
Sun, 12 Nov 2006 07:22:21 +0000 (02:22 -0500) | ||
committer | Shawn O. Pearce <spearce@spearce.org> | |
Sun, 12 Nov 2006 07:22:21 +0000 (02:22 -0500) |
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>
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>
git-gui | patch | blob | history |
index 3cbe3e7f72537a2184df7681cf58e5d44d77509c..040581e8296ad262ed4abfe383b729a7cfb17830 100755 (executable)
--- a/git-gui
+++ b/git-gui
##
## 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
-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"
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
$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 {}
$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...}
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