Revision: 10555 http://pure-data.svn.sourceforge.net/pure-data/?rev=10555&view=rev Author: eighthave Date: 2009-01-14 15:39:26 +0000 (Wed, 14 Jan 2009)
Log Message: ----------- - enabled key bindings to the canvas so typing in boxes is possible
- changed mouse button bindings to be more explicit (Button -> Button-1) and added in some right-click bindings
Modified Paths: -------------- branches/pd-devel/0.41.4/src/pd_bindings.tcl branches/pd-devel/0.41.4/src/pdtk_canvas.tcl
Modified: branches/pd-devel/0.41.4/src/pd_bindings.tcl =================================================================== --- branches/pd-devel/0.41.4/src/pd_bindings.tcl 2009-01-14 15:34:55 UTC (rev 10554) +++ branches/pd-devel/0.41.4/src/pd_bindings.tcl 2009-01-14 15:39:26 UTC (rev 10555) @@ -29,7 +29,7 @@ bind $mytoplevel <$modifier-Key-o> "menu_open" bind $mytoplevel <$modifier-Key-p> "menu_print $mytoplevel" bind $mytoplevel <$modifier-Key-q> "pdsend "pd verifyquit ;"" - bind $mytoplevel <$modifier-Key-r> "menu_raiseconsole" + bind $mytoplevel <$modifier-Key-r> "menu_raise_pdwindow" bind $mytoplevel <$modifier-Shift-Key-L> "menu_clear_console" bind $mytoplevel <$modifier-Shift-Key-Q> "pdsend "pd quit ;"" bind $mytoplevel <$modifier-Shift-Key-R> "menu_toggle_console" @@ -120,25 +120,33 @@ bind $mytoplevel <$modifier-Key-t> "menu_texteditor" }
+ bind $mycanvas <Key> "pdtk_canvas_sendkey %W 1 %K %A 0" + bind $mycanvas <Shift-Key> "pdtk_canvas_sendkey %W 1 %K %A 1" + bind $mycanvas <KeyRelease> "pdtk_canvas_sendkey %W 0 %K %A 0" + # mouse bindings ----------------------------------------------------------- # these need to be bound to $mytoplevel.c because %W will return $mytoplevel for # events over the window frame and $mytoplevel.c for events over the canvas bind $mycanvas <Motion> "pdtk_canvas_motion %W %x %y 0" - bind $mycanvas <Button> "pdtk_canvas_mouse %W %x %y %b 0" - bind $mycanvas <ButtonRelease> "pdtk_canvas_mouseup %W %x %y %b" - bind $mycanvas <$modifier-Button> "pdtk_canvas_mouse %W %x %y %b 0" + bind $mycanvas <Button-1> "pdtk_canvas_mouse %W %x %y %b 0" + bind $mycanvas <ButtonRelease-1> "pdtk_canvas_mouseup %W %x %y %b" + bind $mycanvas <$modifier-Button-1> "pdtk_canvas_mouse %W %x %y %b 0" # TODO look into "virtual events' for a means for getting Shift-Button, etc. switch {$::windowingsystem} { "aqua" { + bind $mycanvas <Button-2> "pdtk_canvas_rightclick %W %x %y %b" # on Mac OS X, emulate a rightclick with Ctrl-click - bind $mycanvas <Ctrl-Button> "pdtk_canvas_rightclick %W %x %y %b" - # TODO try replacing the above with this (and making it global by binding to "." - #bind all <Control-ButtonPress-1> {event generate %W <ButtonPress-2> \ + bind $mycanvas <Ctrl-Button-1> "pdtk_canvas_rightclick %W %x %y %b" + # TODO try replacing the above with this + #bind all <Control-Button-1> {event generate %W <Button-2> \ # -x %x -y %y -rootx %X -rooty %Y \ # -button 2 -time %t} } "x11" { + bind $mycanvas <Button-3> "pdtk_canvas_rightclick %W %x %y %b" # on X11, button 2 "pastes" from the X windows clipboard - bind $mycanvas <Button-2> "pdtk_canvas_clickpaste %W %x %y %b" + bind $mycanvas <Button-2> "pdtk_canvas_clickpaste %W %x %y %b" + } "win32" { + bind $mycanvas <Button-3> "pdtk_canvas_rightclick %W %x %y %b" } } #TODO bind $mytoplevel <MouseWheel>
Modified: branches/pd-devel/0.41.4/src/pdtk_canvas.tcl =================================================================== --- branches/pd-devel/0.41.4/src/pdtk_canvas.tcl 2009-01-14 15:34:55 UTC (rev 10554) +++ branches/pd-devel/0.41.4/src/pdtk_canvas.tcl 2009-01-14 15:39:26 UTC (rev 10555) @@ -22,10 +22,11 @@ } else { # leave room for the menubar wm minsize $mytoplevel 310 30 } - canvas $mytoplevel.c -width $width -height $height -background white \ + set mycanvas $mytoplevel.c + canvas $mycanvas -width $width -height $height -background white \ -highlightthickness 0 # TODO add scrollbars here - pack $mytoplevel.c -side left -expand 1 -fill both + pack $mycanvas -side left -expand 1 -fill both
::pd_bindings::canvas_bindings $mytoplevel
@@ -37,6 +38,9 @@ -command "popup_action $mytoplevel 1" $mytoplevel.popup add command -label "Help" \ -command "popup_action $mytoplevel 2" + + # give focus to the canvas so it gets the events rather than the window + focus $mycanvas }
proc pdtk_canvas_saveas {name initfile initdir} { @@ -75,6 +79,36 @@ }
#------------------------------------------------------------------------------# +# key usage + +proc pdtk_canvas_sendkey {mycanvas state key iso shift} { + if {$key == "BackSpace"} { + set iso "" + set key 8 + } elseif {$key == "Tab"} { + set iso "" + set key 9 + } elseif {$key == "Return"} { + set iso "" + set key 10 + } elseif {$key == "Escape"} { + set iso "" + set key 27 + } elseif {$key == "Space"} { + set iso "" + set key 32 + } elseif {$key == "Delete" || $key == "KP_Delete"} { + set iso "" + set key 127 + } + if {$iso != ""} { + scan $iso %c key + } + puts "pdtk_canvas_sendkey $key" + pdsend "[winfo toplevel $mycanvas] key $state $key $shift ;" +} + +#------------------------------------------------------------------------------# # procs for canvas events
# "map" event tells us when the canvas becomes visible (arg is "0") or
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.