Sujet : Re: event generate send arg
De : rich (at) *nospam* example.invalid (Rich)
Groupes : comp.lang.tclDate : 02. Jan 2025, 05:13:10
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vl53om$366a4$1@dont-email.me>
References : 1
User-Agent : tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.139 (x86_64))
Shaun Kulesa <
user1405@newsgrouper.org.uk.invalid> wrote:
I'm trying to block any user interaction that is not done via `event generate`.
First question is: why? What are you really trying to accomplish?
Next suggestion, have you looked into using 'tk busy' (man n busy). It
might work better than having to remap every single default event
binding within Tk.
To do this I want to break the bindings when $user is not 1.
I want to pass the $user arg to the procedure `block` but I do not
know how to.
Note the documentation for -data in the event manpage:
-data string
String may be any value; it specifies the user_data field for
the event. Only valid for virtual events. Corresponds to the
%d substitution for virtual events in binding scripts.
It tells you how to retreive the '-data' field value, you use the %d
substitution.
But -data is also "only valid for virtual events" which is why you
can't use it with <ButtonPress> (because <ButtonPress> is not a virtual
event).
I thought this is done by -data but I get an error saying I can not
use that with the event <ButtonPress>.
```
package require Tk
button .b -text "Hello, World!"
pack .b -padx 20 -pady 20
proc block {{user 0}} {
if {$user ne 1} {
return -code break
}
return
}
bind .b <ButtonPress> {block}
bind .b <ButtonRelease> {block}
after 1000 [list event generate .b <ButtonPress> -data 1]
```