Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8490
Modified Files: Tag: desiredata desire.tk Log Message: added KeyboardDialog with key listening
Index: desire.tk =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/desire.tk,v retrieving revision 1.1.2.600.2.216 retrieving revision 1.1.2.600.2.217 diff -C2 -d -r1.1.2.600.2.216 -r1.1.2.600.2.217 *** desire.tk 11 Jul 2007 04:59:10 -0000 1.1.2.600.2.216 --- desire.tk 11 Jul 2007 16:07:24 -0000 1.1.2.600.2.217 *************** *** 211,216 **** # foreach x $@subscribers {$x notice $self {expand}$args]} #} ! def Observable changed {args} {foreach x $@subscribers {$x notice $self {expand}$args]}} ! def Observable child_changed {origin args} {foreach x $@subscribers {$x notice $origin {expand}$args]}} } else { def Observable changed {args} {foreach x $@subscribers {eval [concat [list $x notice $self] $args]}} --- 211,216 ---- # foreach x $@subscribers {$x notice $self {expand}$args]} #} ! def Observable changed {args} {foreach x $@subscribers {$x notice $self {expand}$args}} ! def Observable child_changed {origin args} {foreach x $@subscribers {$x notice $origin {expand}$args}} } else { def Observable changed {args} {foreach x $@subscribers {eval [concat [list $x notice $self] $args]}} *************** *** 330,339 **** set subpatcherize(edit2) "" #-----------------------------------------------------------------------------------# ! class_new EventList {Observable Thing}
! def EventList init {} {super; set @list {}} ! def EventList add {e} {lappend @list $e; $self changed} ! def EventList list {} {lreverse $@list} ! set ::event_history [EventList new]
#-----------------------------------------------------------------------------------# --- 330,339 ---- set subpatcherize(edit2) "" #-----------------------------------------------------------------------------------# ! class_new EventHistory {Observable Thing}
! def EventHistory init {} {super; set @list {}} ! def EventHistory add {e} {lappend @list $e; $self changed add $e} ! def EventHistory list {} {lreverse $@list} ! set ::event_history [EventHistory new]
#-----------------------------------------------------------------------------------# *************** *** 7889,7892 **** --- 7889,7946 ----
#---------------------------------------------------------------- + + class_new KeyboardDialog {Dialog} + + set keyboard_layout { + {Escape F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12} + {grave 1 2 3 4 5 6 7 8 9 0 minus equal BackSpace} + {Tab q w e r t y u i o p bracketleft bracketright backslash} + {Caps_Lock a s d f g h j k l semicolon apostrophe Return} + {Shift_L z x c v b n m comma period slash Shift_R} + {Control_L Super_L Alt_L space Alt_R Super_R Menu Control_R} + } + + foreach {k v} { + grave ` minus - equal = bracketleft [ bracketright ] backslash \ + semicolon ; apostrophe ' comma , period . slash / + Shift_L Shift Shift_R Shift Control_L Ctrl Control_R Ctrl Alt_L Alt Alt_R AltGr + Super_L Win Super_R Win + } {set keyboard_rename($k) $v} + + def KeyboardDialog init {} { + super close + set @history $::event_history + wm title .$self "Keyboard View" ;# say + set i 0 + foreach row $::keyboard_layout { + frame .$self.$i + foreach key $row { + set ::keyboard_rowof($key) $i + #pack [button .$self.$i.key$key -text "$key"] -side left + if {[info exists ::keyboard_rename($key)]} {set text $::keyboard_rename($key)} {set text $key} + pack [label .$self.$i.key$key -text " $text " -relief raise -border 4 -bg "#dddddd"] -side left + } + pack .$self.$i -fill x + incr i + } + $@history subscribe $self + } + + def KeyboardDialog notice {origin add event} { + mset {type k x y w} $event + if {![info exists ::keyboard_rowof($k)]} {puts "unknown event $event"; return} + set row $::keyboard_rowof($k) + switch -- $type { + KeyPress {puts "$k on"; .$self.$row.key$k configure -bg "#ff0000"} + KeyRelease {puts "$k off"; .$self.$row.key$k configure -bg "#dddddd"} + } + } + + def KeyboardDialog delete {} { + $@history unsubscribe $self + super + } + + #---------------------------------------------------------------- # Deconstructors
*************** *** 8082,8083 **** --- 8136,8140 ---- } } + + after 100 {KeyboardDialog new} +