blackadder has asked for the wisdom of the Perl Monks concerning the following question:

Greatings

I have a Tk based form; in this form I have few icons (these icons represent user and group account). I would like to be able to program the double click button, so that when pointing at an icon representing user BloggsJ’s account and by double clicking on this icon I can obtain the text relating to this icon
$tk_form{output_list}-> bind('<Double-Button-1>',sub { print "\nUser clicked on account icon in Output_list\n"; # # Here I need a bit of code that will retrieve the information # regarding the icon that’s been double-clicked on (only the # text – ie.account name is required) # });
Any enlightens or “Perls of wisdoms” are highly appreciated.
Many Thanks
Blackadder

Replies are listed 'Best First'.
Re: Binding double click in a Perl/Tk form
by hiseldl (Priest) on Aug 19, 2002 at 19:32 UTC
    What kind of widget is the $tk_form{output_list}? ListBox? HList? Tree?

    Until you post what type of widget you are using, you could use the following general steps:

    1. fetch the coordinates of the mouse double-click event
    2. using the coordinates, find out which 'list' item has been clicked on
    3. get the item text, i.e. for an HList--$hlist->entrycget(-text)

    Other links that may help:

    --
    hiseldl

      Its a Tlist...

      $tk{output_list} = $tk{right_frame}->Scrolled('TList', -height=>'1', -width=>'1', -scrollbars=>'osoe',);

      Many thanks for your contributions...Its is your Drag and Drop example that I have originally used, sparked and started everything off (well this project at least). My whole project is based on this example.

      By the way: how can I get a further sub window to take control of the main Tk window “what I call a form” (like a dialog window but also requires user input) and the controls should remains with this sub windows until the user has responded with an input, (I can create the sub window, but I don't know exactly how to keep the control focused on it ).


      Many thanks

      Blackadder
          By the way: how can I get a further sub window to take control of the main Tk window “what I call a form” (like a dialog window but also requires user input) and the controls should remains with this sub windows until the user has responded with an input, (I can create the sub window, but I don't know exactly how to keep the control focused on it ).

        Do you mean a modal dialog? e.g. a dialog that keeps focus until the 'OK' or 'Cancel' buttons (or whatever buttons) are pressed and doesn't let the user input anything on the main window.

        Also, try binding the double click event directly to the Icon, Label or whatever instead of to the TList, this should work equally as well. Just substitute $tk_form{output_list} with your Label widget, i.e. $tk_form{label}->bind(...). Then let me know if this doesn't work so we can work it out the hard way by figuring out which element of the TList was clicked, etc.

        --
        hiseldl