Skip to content

Commit b000886

Browse files
committed
[[ Bug 14541 ]] Wait for menu to close before returning from MCWidgetExecPopupMenuAtLocation
1 parent 468fd3d commit b000886

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

engine/src/button.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3835,6 +3835,15 @@ void MCButton::setupmenu()
38353835
flags = MENU_FLAGS;
38363836
}
38373837

3838+
bool MCButton::menuisopen()
3839+
{
3840+
#ifdef _MAC_DESKTOP
3841+
return macmenuisopen();
3842+
#else
3843+
return menu != nil && menu->getopened();
3844+
#endif
3845+
}
3846+
38383847
bool MCButton::selectedchunk(MCStringRef& r_string)
38393848
{
38403849
MCExecContext ctxt(nil, nil, nil);

engine/src/button.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,9 @@ class MCButton : public MCControl
303303
MCRange getmenurange();
304304
void docascade(MCStringRef t_pick);
305305
void setupmenu();
306+
307+
bool menuisopen();
308+
306309
bool selectedchunk(MCStringRef& r_string);
307310
bool selectedline(MCStringRef& r_string);
308311
bool selectedtext(MCStringRef& r_string);
@@ -335,6 +338,8 @@ class MCButton : public MCControl
335338
void macopenmenu(void);
336339
void macfreemenu(void);
337340
static void getmacmenuitemtextfromaccelerator(MCPlatformMenuRef menu, KeySym key, uint1 mods, MCStringRef &r_string, bool issubmenu);
341+
342+
bool macmenuisopen();
338343
#endif
339344

340345
MCCdata *getcdata(void) {return bdata;}

engine/src/desktop-menu.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,11 @@ void MCButton::getmacmenuitemtextfromaccelerator(MCPlatformMenuRef menu, KeySym
502502
{
503503
}
504504

505+
bool MCButton::macmenuisopen()
506+
{
507+
return m_system_menu != nil;
508+
}
509+
505510
////////////////////////////////////////////////////////////////////////////////
506511

507512
// This structure holds info about each currently set main menu.

engine/src/widget.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2131,6 +2131,15 @@ extern "C" MC_DLLEXPORT MCStringRef MCWidgetExecPopupMenuAtLocation(MCStringRef
21312131

21322132
MCInterfaceExecPopupButton(ctxt, t_button, t_at_ptr);
21332133

2134+
while (t_button->menuisopen() && !MCquit)
2135+
{
2136+
MCU_resetprops(True);
2137+
// MW-2011-09-08: [[ Redraw ]] Make sure we flush any updates.
2138+
MCRedrawUpdateScreen();
2139+
MCscreen->siguser();
2140+
MCscreen->wait(REFRESH_INTERVAL, True, True);
2141+
}
2142+
21342143
t_button->SetVisible(ctxt, 0, false);
21352144
t_button->del();
21362145
t_button->scheduledelete();

0 commit comments

Comments
 (0)