Deutsch   English   Français   Italiano  
<vafl3j$24vu0$1@paganini.bofh.team>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!weretis.net!feeder8.news.weretis.net!newsfeed.bofh.team!paganini.bofh.team!not-for-mail
From: Ian <gay@sfuu.ca>
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
Bytes: 2225

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