Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Thanks for the reply again. I've almost made it work. My problem now is that the y-coordinate returned gets interpreted by nearest() in a way that I don't expect: nearest() seems to expect a y-coordinate relative to the top of the listbox widget, but the y-coordinate given is actually the absolute, screen, coordinate.

Here's my code snippet:

$list->g_bind("<Motion>", [sub { my($x,$y) = @_; my @sel_list = $list->curselection(); my $on_target = 0; my $current_index = $list->nearest($y); print "y = " . $y . "current_index = " . $current_index . "\n"; # +test if (length($sel_list[0]) > 0) { my @sel_list_items = split(/ /,$sel_list[0]); if (scalar(@sel_list_items) > 1) { foreach my $sel_list_item (@sel_list_items) { print "sel_list_item = " . $sel_list_item . "\n"; # te +st if ($sel_list_item eq $current_index) { $on_target = 1; } } } } print "on_target = " . $on_target . "\n"; # test if ($on_target == 1) { $listmenu->g_tk___popup($x,$y) } }, Tkx::Ev("%X", "%Y")]);

I can see that the current_index is always larger than I would expect it to be. Apologies if I am missing something simple!

In reply to Re^4: Tkx g_bind to menu on listbox only for selected row by v4169sgr
in thread Tkx g_bind to menu on listbox only for selected row by v4169sgr

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others chilling in the Monastery: (6)
    As of 2018-06-21 13:28 GMT
    Find Nodes?
      Voting Booth?
      Should cpanminus be part of the standard Perl release?

      Results (118 votes). Check out past polls.