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

PopupMenu: Add missing target components for menus created by built-in widgets

This commit is contained in:
reuk 2025-05-29 17:28:18 +01:00
parent 336a475921
commit b20df8d713
No known key found for this signature in database
6 changed files with 14 additions and 9 deletions

View file

@ -829,7 +829,7 @@ private:
setContentOwned (content, resizeAutomatically);
}
void buttonClicked (Button*) override
void buttonClicked (Button* button) override
{
PopupMenu m;
m.addItem (1, TRANS ("Audio/MIDI Settings..."));
@ -839,7 +839,7 @@ private:
m.addSeparator();
m.addItem (4, TRANS ("Reset to default state"));
m.showMenuAsync (PopupMenu::Options(),
m.showMenuAsync (PopupMenu::Options().withTargetComponent (button),
ModalCallbackFunction::forComponent (menuCallback, this));
}

View file

@ -102,12 +102,17 @@ public:
}
}
void cellClicked (int rowNumber, int columnId, const juce::MouseEvent& e) override
void cellClicked (int rowNumber, int columnId, const MouseEvent& e) override
{
TableListBoxModel::cellClicked (rowNumber, columnId, e);
if (rowNumber >= 0 && rowNumber < getNumRows() && e.mods.isPopupMenu())
owner.createMenuForRow (rowNumber).showMenuAsync (PopupMenu::Options().withDeletionCheck (owner));
{
owner.createMenuForRow (rowNumber)
.showMenuAsync (PopupMenu::Options().withTargetComponent (e.originalComponent)
.withMousePosition()
.withDeletionCheck (owner));
}
}
void deleteKeyPressed (int) override

View file

@ -672,7 +672,7 @@ public:
m.addSubMenu (TRANS ("Rotary mode"), rotaryMenu);
}
m.showMenuAsync (PopupMenu::Options(),
m.showMenuAsync (PopupMenu::Options().withTargetComponent (owner).withMousePosition(),
ModalCallbackFunction::forComponent (sliderMenuCallback, &owner));
}

View file

@ -912,7 +912,7 @@ void TableHeaderComponent::showColumnChooserMenu (const int columnIdClicked)
{
m.setLookAndFeel (&getLookAndFeel());
m.showMenuAsync (PopupMenu::Options(),
m.showMenuAsync (PopupMenu::Options().withTargetComponent (this).withMousePosition(),
ModalCallbackFunction::forComponent (tableHeaderMenuCallback, this, columnIdClicked));
}
}

View file

@ -1581,8 +1581,8 @@ void TextEditor::mouseDown (const MouseEvent& e)
menuActive = true;
m.showMenuAsync (PopupMenu::Options(),
[safeThis = SafePointer<TextEditor> { this }] (int menuResult)
m.showMenuAsync (PopupMenu::Options().withTargetComponent (this).withMousePosition(),
[safeThis = SafePointer { this }] (int menuResult)
{
if (auto* editor = safeThis.getComponent())
{

View file

@ -1563,7 +1563,7 @@ void CodeEditorComponent::mouseDown (const MouseEvent& e)
m.setLookAndFeel (&getLookAndFeel());
addPopupMenuItems (m, &e);
m.showMenuAsync (PopupMenu::Options(),
m.showMenuAsync (PopupMenu::Options().withTargetComponent (this).withMousePosition(),
ModalCallbackFunction::forComponent (codeEditorMenuCallback, this));
}
else