Re: Tkx: Usage for binding with multiple parameters

[email protected] (Matthias Hofer) Thu, 01 Jun 2017 08:16:53 +0000
Newsgroups perl.tcltk
Message-ID <20170601081653.Horde.O7bxCX_H4qvdpwlHXhi2zw1@webmail.the-lions.org>
Hi Jeff,

> On May 31, 2017, at 1:42 AM, Matthias Hofer <[email protected]> wrote:
>> I'm using Tkx for my nice interface, and so far things work great.
>>
>> But I don't get to work a specific thing I need to do: In  
>> "scale.tcl", there are bindings like
>>
>>    bind TScale <ButtonPress-1>   { ttk::scale::Press %W %x %y }
>>
>> I'd like to change that in my Perl program to
>>
>>    bind TScale <ButtonPress-1>   { ttk::scale::Jump %W %x %y }
>>
>> I can't figure out how to execute the latter command via Tkx in  
>> Perl. Tkx::Ev does only work for one argument, but here three are  
>> expected.
>
> I believe http://www.tkdocs.com/tutorial/concepts.html points in the  
> right direction. Doing this completely blind, but I think it would  
> look like:
>
> Tkx::bind(“TScale”, “<ButtonPress-1>”, [sub { my($W, $x, $y) = @_;
>       # insert action here
> }, Tkx::Ev(“%W”, "%x", "%y")]);
>
> but it looks like you just want to use pure Tcl actually, so that is  
> more simply:
>
> Tkx::bind(“TScale”, “<ButtonPress-1>”, “ttk::scale::Jump %W %x %y”);

I just tried the simple version, and it just works!
I don't know why I did not came up with that, as I have read the docs  
thoroughly and more than once, but probably I just twisted my thoughts  
into a too complicated way ...

Thank you very much!

Regards,

Matthias