in reply to Re: TrackPopupMenu delay
in thread TrackPopupMenu delay

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.

Replies are listed 'Best First'.
Re^3: TrackPopupMenu delay
by Anonymous Monk on Oct 08, 2008 at 15:49 UTC
    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