Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

BOFH excuse #65: system needs to be rebooted


comp / comp.lang.tcl / Re: How to simulate a 'shift click'

SubjectAuthor
* How to simulate a 'shift click'Helmut Giese
`* Re: How to simulate a 'shift click'Ian
 `- Re: How to simulate a 'shift click'Helmut Giese

1
Subject: How to simulate a 'shift click'
From: Helmut Giese
Newsgroups: comp.lang.tcl
Organization: ratiosoft
Date: Sun, 25 Aug 2024 15:55 UTC
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: hgiese@ratiosoft.com (Helmut Giese)
Newsgroups: comp.lang.tcl
Subject: How to simulate a 'shift click'
Date: Sun, 25 Aug 2024 17:55:07 +0200
Organization: ratiosoft
Lines: 38
Message-ID: <9bkmcjtdlvvv4o5vpvq2hobtmt3413okto@4ax.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 25 Aug 2024 17:55:07 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="64491b887b473344a7ffe3e212eaabca";
logging-data="2061137"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+U1NXbxiArX9ixydGq2Blz"
Cancel-Lock: sha1:EyVBpPZe7KkhNVopGBl2QT068jQ=
X-Newsreader: Forte Free Agent 1.93/32.576 English (American)
View all headers

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

Subject: Re: How to simulate a 'shift click'
From: Ian
Newsgroups: comp.lang.tcl
Organization: To protect and to server
Date: Sun, 25 Aug 2024 16:11 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!newsfeed.bofh.team!paganini.bofh.team!not-for-mail
From: gay@sfuu.ca (Ian)
Newsgroups: comp.lang.tcl
Subject: Re: How to simulate a 'shift click'
Date: Sun, 25 Aug 2024 09:11:31 -0700
Organization: To protect and to server
Lines: 45
Message-ID: <vafl3j$24vu0$1@paganini.bofh.team>
References: <9bkmcjtdlvvv4o5vpvq2hobtmt3413okto@4ax.com>
Reply-To: gay@sfuu.ca
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7Bit
Injection-Info: paganini.bofh.team; logging-data="2260928"; posting-host="dVmdk8o8gtvo/mFhg6pl1g.user.paganini.bofh.team"; mail-complaints-to="usenet@bofh.team"; posting-account="9dIQLXBM7WM9KzA+yjdR4A";
User-Agent: KNode/0.10.9
X-Notice: Filtered by postfilter v. 0.9.3
View all headers

Helmut Giese wrote:

> 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?

--
*********** To reply by e-mail, make w single in address **************

Subject: Re: How to simulate a 'shift click'
From: Helmut Giese
Newsgroups: comp.lang.tcl
Organization: ratiosoft
Date: Sun, 25 Aug 2024 18:24 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: hgiese@ratiosoft.com (Helmut Giese)
Newsgroups: comp.lang.tcl
Subject: Re: How to simulate a 'shift click'
Date: Sun, 25 Aug 2024 20:24:18 +0200
Organization: ratiosoft
Lines: 6
Message-ID: <5itmcj967ldv3d4tm8k31aefj7m1i57gue@4ax.com>
References: <9bkmcjtdlvvv4o5vpvq2hobtmt3413okto@4ax.com> <vafl3j$24vu0$1@paganini.bofh.team>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 25 Aug 2024 20:24:19 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="64491b887b473344a7ffe3e212eaabca";
logging-data="2158561"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18RZ3L1KpovB8ElqvulUoiH"
Cancel-Lock: sha1:N/3PhgUM10wg0TP/CxP2ueKMqHs=
X-Newsreader: Forte Free Agent 1.93/32.576 English (American)
View all headers

Hello Ian,
>
>Have you tried using the -state parameter to event generate?

yeah, that did the trick. You're a genius :), many thanks
Helmut

1

rocksolid light 0.9.8
clearnet tor