Hello out there,
I can simulate a simple click but fail at a 'shift click'.
Below is what I tried:
---
package require Tk
foreach ch [winfo children "."] {destroy $ch}
# create a test app
set btn [ttk::button .btn -text "Press me"]
pack $btn
# add some bindings
bind $btn <Button-1> {puts "Simple click"}
bind $btn <Shift-Button-1> {puts "Shift click"}
focus $btn
set x [winfo x $btn] ; set y [winfo y $btn]
# place the mouse
event generate "." <Motion> -x [incr x 50] -y [incr y 10] -warp 1
event generate $btn <ButtonPress-1>
after 100 ; event generate $btn <ButtonRelease-1>
# now a 'shift click'
if 1 {
event generate $btn <KeyPress> -keysym Shift_L
} else {
event generate $btn <Key-Shift_L>
}
event generate $btn <ButtonPress-1>
after 100 ; event generate $btn <ButtonRelease-1>
event generate $btn <KeyRelease> -keysym Shift_L
---
All I ever get is twice 'Simple click' - no matter whether I use <Key-Shift_L> or the longer form, wether I generate the keypress for
$btn or ".". I am out of ideas what to try next.
Any help will be greatly appreciated
Helmut.
PS: This is on Windows with Tcl 8.6.10
Have you tried using the -state parameter to event generate?
Sysop: | DaiTengu |
---|---|
Location: | Appleton, WI |
Users: | 991 |
Nodes: | 10 (0 / 10) |
Uptime: | 119:28:29 |
Calls: | 12,958 |
Files: | 186,574 |
Messages: | 3,265,636 |