Browse Source

Implement the menuActive flag in TextEditor

tags/2021-05-28
ed 7 years ago
parent
commit
5b32ef4897
1 changed files with 14 additions and 7 deletions
  1. +14
    -7
      modules/juce_gui_basics/widgets/juce_TextEditor.cpp

+ 14
- 7
modules/juce_gui_basics/widgets/juce_TextEditor.cpp 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);
}
});
}
}
}


Loading…
Cancel
Save