Deutsch   English   Français   Italiano  
<v634bjhn84dkb3easgcapqlpfdi26ujm2e@4ax.com>

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

Path: ...!feeds.phibee-telecom.net!3.eu.feeder.erje.net!feeder.erje.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Helmut Giese <hgiese@ratiosoft.com>
Newsgroups: comp.lang.tcl
Subject: Re: Generate <Shift-Button> event on a canvas (on Windows)
Date: Tue, 06 Aug 2024 14:10:30 +0200
Organization: ratiosoft
Lines: 29
Message-ID: <v634bjhn84dkb3easgcapqlpfdi26ujm2e@4ax.com>
References: <qfq1bj95rbgdrlnth8qp03c22cbqrhkn4h@4ax.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 06 Aug 2024 14:10:32 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="8376e6914f4eb196635c2c2c3b96b7e2";
	logging-data="1672834"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+Icx3gNuCfrXpVh/gOfiq3"
Cancel-Lock: sha1:2TLFvQul2wdlz6Yla4ZjSZ9NnTY=
X-Newsreader: Forte Free Agent 1.93/32.576 English (American)
Bytes: 2012

To answer my own question: The following script does the trick.
	---
package require Tk
foreach ch [winfo children .] {destroy $ch}

set fr [ttk::frame .fr]
set btn1 [ttk::button $fr.btn1 -text "Simple click"]
set btn2 [ttk::button $fr.btn2 -text "Shift click"]
pack $btn1 $btn2
pack $fr

bind $btn1 <Button-1> {puts "Simple click"}
bind $btn2 <Shift-Button-1> {puts "Shift click"}

puts -nonewline "Press <Enter> to watch a message appear ... "
gets stdin
event generate $btn1 <Button-1>
puts -nonewline "Press <Enter> to watch another message appear ... "
gets stdin
event generate $btn2 <Button-1> -state 31
	---
The trick is the '-state 31' to achieve a 'Shift click'. I discovered
this flag / option on the event manual page where it was mentioned
that it 'Corresponds to the %s substitution for binding scripts.'
Then it was only a matter of trying out what a 'Shift click' produced
with '%s'.

I hope this will be useful to some of you some time ...
Helmut