1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-20 01:14:20 +00:00

Implement the menuActive flag in TextEditor

This commit is contained in:
ed 2018-01-08 10:18:03 +00:00
parent 9046453701
commit 5b32ef4897

View file

@ -1691,12 +1691,6 @@ void TextEditor::performPopupMenuAction (const int menuItemID)
}
}
static void textEditorMenuCallback (int menuResult, TextEditor* editor)
{
if (editor != nullptr && menuResult != 0)
editor->performPopupMenuAction (menuResult);
}
//==============================================================================
void TextEditor::mouseDown (const MouseEvent& e)
{
@ -1716,8 +1710,21 @@ void TextEditor::mouseDown (const MouseEvent& e)
m.setLookAndFeel (&getLookAndFeel());
addPopupMenuItems (m, &e);
menuActive = true;
SafePointer<TextEditor> safeThis (this);
m.showMenuAsync (PopupMenu::Options(),
ModalCallbackFunction::forComponent (textEditorMenuCallback, this));
[safeThis] (int menuResult)
{
if (auto* editor = safeThis.getComponent())
{
editor->menuActive = false;
if (menuResult != 0)
editor->performPopupMenuAction (menuResult);
}
});
}
}
}