Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

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.

Replies are listed 'Best First'.
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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://351797]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2017-10-23 08:56 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (277 votes). Check out past polls.