That is what I am doing (except I am using "-onClick => $callback, -onRightClick => $callback2" in "$window->AddNotifyIcon(...);" instead of using Name_Event). The example I gave was just simplified to show the problem and nothing else. When I use TrackPopupMenu in either case, the menu callback doesn't execute until TrackPopupMenu is called a second time, as illustrated by the simplified example. | [reply] |
Hello,
I got this to work by creating the menu outside of the subroutine, then calling the menu inside of the subroutine. Here's what I mean:
use Win32::GUI ();
...
my $menu = Win32::GUI::Menu->new(-name => "TestMenu");
$menu->{"TestMenu"}->AddMenuItem(
-item => 0,
-id => 14,
-text => "Exit",
-onClick => sub { $win->Hide(); undef $win; exit(0); },
);
sub Tray_RightClick {
$win->TrackPopupMenu($menu->{"TestMenu"}, Win32::GUI::GetCursorPos());
return 1;
}
...
Hope this helps you...
~Morpheous1129
| [reply] |