Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Tk event bindings - single vs. double click

by arden (Curate)
on May 09, 2004 at 03:25 UTC ( #351797=note: print w/ replies, xml ) Need Help??


in reply to Tk event bindings - single vs. double click

I'm not sure if there's an easy way to tell if a it's a double-click within the sub-routine (aside from forcing one sleep of a second and checking if the sub is called again at the end of that second).

However, according to the Perl Cookbook 1st edition, recipe 15.19, you can bind a subroutine to a <Double-Button> like this:

# permit viewing by binding double-click $l->bind( '<Double-Button>' => \&view );
I haven't any experience with it though. Chapter 14 of Learning Perl/Tk mentions it as <Double-Button-1> though. Of course, Learning Perl/Tk is no longer in print, so you'd have to buy it second-hand. You might also wish to take a look at the second edition of the Perl Cookbook, as it might have more details. Give these a try and let us know what works/doesn't work. . .

- - arden.


Comment on Re: Tk event bindings - single vs. double click
Download Code
Re: Re: Tk event bindings - single vs. double click
by Ven'Tatsu (Deacon) on May 09, 2004 at 03:43 UTC
    Since Perl is not (usualy) multi-threading (and when it is Tk is not thread safe), sleeping will delay TK's processing of events, meaning that you still can't see that there is a double click from inside a sub called from the single click event.
    Now that I think of it though, $mw->update() should let Tk notice the double click, but I don't know how you would catch that from inside the sub, and I would think it would beg for odd timing issues to crop up.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://351797]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2014-09-18 07:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (109 votes), past polls