Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit e5f65df

Browse files
[[ Bug 16218 ]] Better check that Mac popup menu had an item selected
The function popUpMenuPositioningItem always returns true if the popup menu was open by keeping the mouse down - even if the mouse is released without selecting any item. Fixed by adding a static bool set to true when itemMenuSelected is called.
1 parent 971693b commit e5f65df

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

docs/notes/bugfix-16218.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Popup menu can get corrupted when click-drag out of the list

engine/src/mac-menu.mm

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@
4141
// SN-2014-11-10: [[ Bug 13836 ]] Keeps the track about the open items in the menu bar.
4242
static uint32_t s_open_menubar_items = 0;
4343

44+
// SN-2015-11-02: [[ Bug 16218 ]] We can't trust popUpMenuPositioningItem on
45+
// returning whether an item has been selected.
46+
static bool s_menu_item_selected = false;
47+
4448

4549
////////////////////////////////////////////////////////////////////////////////
4650

@@ -204,7 +208,10 @@ - (void)menuItemSelected: (id)sender
204208
t_quit_accelerator_present = [(com_runrev_livecode_MCMenuDelegate *)[[t_item menu] delegate] platformMenuRef] -> quit_item != nil;
205209

206210
if (s_menu_select_lock == 0 || t_quit_accelerator_present)
211+
{
207212
MCPlatformCallbackSendMenuSelect(m_menu, [[t_item menu] indexOfItem: t_item]);
213+
s_menu_item_selected = true;
214+
}
208215

209216
// SN-2014-11-06: [[ Bug 13836 ]] s_menu_select_occured was not used.
210217
}
@@ -858,12 +865,17 @@ bool MCPlatformPopUpMenu(MCPlatformMenuRef p_menu, MCPlatformWindowRef p_window,
858865

859866
// MW-2014-07-29: [[ Bug 12990 ]] If item is UINDEX_MAX then don't specify an item, thus preventing
860867
// one from being highlighted.
861-
bool t_result;
862-
t_result = [t_menu popUpMenuPositioningItem: p_item == UINDEX_MAX ? nil : [t_menu itemAtIndex: p_item] atLocation: t_location inView: t_view];
868+
869+
// SN-2015-11-02: [[ Bug 16218 ]] popUpMenuPositioningItem always returns
870+
// true if the menu is open by keeping the mouse down, even if the mouse is
871+
// released outside of the menu list.
872+
// We will set s_menu_item_selected in menuItemSelected if selection occurs.
873+
s_menu_item_selected = false;
874+
[t_menu popUpMenuPositioningItem: p_item == UINDEX_MAX ? nil : [t_menu itemAtIndex: p_item] atLocation: t_location inView: t_view];
863875

864876
MCMacPlatformSyncMouseAfterTracking();
865877

866-
return t_result;
878+
return s_menu_item_selected;
867879
}
868880

869881
//////////

0 commit comments

Comments
 (0)