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:
parent
9046453701
commit
5b32ef4897
1 changed files with 14 additions and 7 deletions
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue