Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

BOFH excuse #162: bugs in the RAID


comp / comp.lang.tcl / Re: event generate send arg

SubjectAuthor
* event generate send argShaun Kulesa
`* Re: event generate send argRich
 +- Re: event generate send argShaun Kulesa
 `- Re: event generate send argShaun Kulesa

1
Subject: event generate send arg
From: Shaun Kulesa
Newsgroups: comp.lang.tcl
Date: Wed, 1 Jan 2025 23:59 UTC
Path: news.eternal-september.org!eternal-september.org!newsgrouper.org.uk!.POSTED!not-for-mail
From: user1405@newsgrouper.org.uk.invalid (Shaun Kulesa)
Newsgroups: comp.lang.tcl
Subject: event generate send arg
Date: Wed, 01 Jan 2025 23:59:41 GMT
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Message-ID: <1735775981-1405@newsgrouper.org.uk>
Injection-Info: newsgrouper.org.uk; mail-complaints-to="newsgrouper@yahoo.com"; posting-account=user1405
Injection-Date: Wed, 01 Jan 2025 23:59:41 GMT
User-Agent: Newsgrouper/0.7.0
View all headers

I'm trying to block any user interaction that is not done via `event generate`.
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.
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]
```

Subject: Re: event generate send arg
From: Rich
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Thu, 2 Jan 2025 04:13 UTC
References: 1
Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: event generate send arg
Date: Thu, 2 Jan 2025 04:13:10 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 51
Message-ID: <vl53om$366a4$1@dont-email.me>
References: <1735775981-1405@newsgrouper.org.uk>
Injection-Date: Thu, 02 Jan 2025 05:13:11 +0100 (CET)
Injection-Info: dont-email.me; posting-host="6420596632e4571cd84179c8b721a5c9";
logging-data="3348804"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/dTF1li54HWEvkRclBcg2m"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.139 (x86_64))
Cancel-Lock: sha1:3BQRu1tt/LwUjedAnSq0UhoA54g=
View all headers

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]
> ```

Subject: Re: event generate send arg
From: Shaun Kulesa
Newsgroups: comp.lang.tcl
Date: Thu, 2 Jan 2025 10:25 UTC
References: 1 2
Path: news.eternal-september.org!eternal-september.org!newsgrouper.org.uk!.POSTED!not-for-mail
From: user1405@newsgrouper.org.uk.invalid (Shaun Kulesa)
Newsgroups: comp.lang.tcl
Subject: Re: event generate send arg
References: <1735775981-1405@newsgrouper.org.uk> <vl53om$366a4$1@dont-email.me>
Date: Thu, 02 Jan 2025 10:25:18 GMT
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Message-ID: <1735813518-1405@newsgrouper.org.uk>
Injection-Info: newsgrouper.org.uk; mail-complaints-to="newsgrouper@yahoo.com"; posting-account=user1405
Injection-Date: Thu, 02 Jan 2025 10:25:18 GMT
User-Agent: Newsgrouper/0.7.0
View all headers

> First question is: why? What are you really trying to accomplish?

I am running live clones of a Tk GUI over a server.

These clones are just a clone of the host GUI which I do by collecting all the widget data from the host and then rebuild in the clients.

I use a library that tells me all events that have happened, it tells me if it was done by manual interaction or by `event generate`.

I want the clients manual interactions to be sent to the server to dispute whether they are up to date with the other clients.

Therefore I want the client to be able to gather their input but not act on it unless the server agrees.

Subject: Re: event generate send arg
From: Shaun Kulesa
Newsgroups: comp.lang.tcl
Date: Thu, 2 Jan 2025 12:57 UTC
References: 1 2
Path: news.eternal-september.org!eternal-september.org!newsgrouper.org.uk!.POSTED!not-for-mail
From: user1405@newsgrouper.org.uk.invalid (Shaun Kulesa)
Newsgroups: comp.lang.tcl
Subject: Re: event generate send arg
References: <1735775981-1405@newsgrouper.org.uk> <vl53om$366a4$1@dont-email.me>
Date: Thu, 02 Jan 2025 12:57:38 GMT
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Message-ID: <1735822658-1405@newsgrouper.org.uk>
Injection-Info: newsgrouper.org.uk; mail-complaints-to="newsgrouper@yahoo.com"; posting-account=user1405
Injection-Date: Thu, 02 Jan 2025 12:57:38 GMT
User-Agent: Newsgrouper/0.7.0
View all headers

I just realised since the package I'm using already decides what is synthetic and what is real I can just copy it.

According the co-pilot it checks the time %t and if it is equal to 0 then it is a synthetic `event generate`.

1

rocksolid light 0.9.8
clearnet tor