Oops. There is bug in the above under Linux (but not MS windows and OS-X).
If you don't select a popup menu item, the popup stays there--clicking elsewhere in the window does not close it. You can end up with dozens of them scattering the landscape.
The only 'cure' I can find is store the menu which has been popped up in a global, and bind a left mouse down event to unpost the global (ignored by Windoze and OS-X which intrinsically remove popup menus). Probably should bind the Escape key to do the same.
Ugly, ugly. There HAS to be a better way!!
my $oldmenu;
...
sub add_edit_popup
{
...
$obj->bind('<3>',
[sub { my ($w, $x, $y) = @_; $menu->post($x, $y);
$oldmenu = $menu; }, Ev('X'), Ev('Y'), ]);
$mw->bind('<ButtonPress-1>',
[sub { if ($oldmenu) { $oldmenu->unpost; } undef $oldmenu; } ]);
}
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, details, 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, summary, 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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.