Detailed steps on how to reproduce the bug
When compiled as a standalone app on OSX with juce 8.0.12, TextEditor set inside a PopupMenu::CustomComponent are not editable. On linux and windows and even on OSX as a plugin it works but standalone its impossible to edit the text.
By using a subclass of TextEditor and some other code to make sure that the PopupMenu doesn't close too fast, I'm able to see that clicks are registered, the location of the caret changes but keyPressed is never called. onReturnKey is never called either.
Here is some code to reproduce the issue. I have reproduced it with a projucer GUI template and the following code:
Custom popupmenu h file:
#pragma once
#include <JuceHeader.h>
class PopupTextEditor
: public juce::PopupMenu::CustomComponent
{
public:
void getIdealSize(int & idealWidth, int & idealHeight) override;
void initPopupTextEditor(std::unique_ptr<juce::TextEditor> textEditor);
private:
std::unique_ptr<juce::TextEditor> mPopupTextEditor;
JUCE_LEAK_DETECTOR(PopupTextEditor)
};
custom popupmenu cpp file:
#include "cg_PopupTextEditor.h"
//==============================================================================
void PopupTextEditor::getIdealSize(int & idealWidth, int & idealHeight)
{
idealWidth = mPopupTextEditor->getWidth();
idealHeight = mPopupTextEditor->getHeight();
}
//==============================================================================
void PopupTextEditor::initPopupTextEditor(std::unique_ptr<juce::TextEditor> textEditor)
{
mPopupTextEditor = std::move(textEditor);
addAndMakeVisible(*mPopupTextEditor);
}
main component h file
#pragma once
#include <JuceHeader.h>
#include <memory>
class MainComponent : public juce::Component
{
public:
//==============================================================================
MainComponent();
~MainComponent() override;
//==============================================================================
void paint (juce::Graphics&) override;
void resized() override;
juce::PopupMenu pop;
private:
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainComponent)
};
main component cpp file
#include "MainComponent.h"
#include "cg_PopupTextEditor.h"
//==============================================================================
MainComponent::MainComponent()
{
setSize (600, 400);
auto edit = std::make_unique<juce::TextEditor>("text editor");
edit->setSize(60, 20);
edit->setText("3434");
edit->selectAll();
auto popup{std::make_unique<PopupTextEditor>()};
popup->initPopupTextEditor(std::move(edit));
pop.clear();
pop.addCustomItem(1, std::move(popup), nullptr, "text editor");
pop.showMenuAsync(juce::PopupMenu::Options(), [](int res){});
}
MainComponent::~MainComponent()
{
}
//==============================================================================
void MainComponent::paint (juce::Graphics& g)
{
}
void MainComponent::resized()
{
}
What is the expected behaviour?
The value of the texteditor should be editable with the keyboard
Operating systems
macOS
What versions of the operating systems?
Tahoe 26.2
Architectures
Arm64/aarch64
Stacktrace
Plug-in formats (if applicable)
Standalone
Plug-in host applications (DAWs) (if applicable)
No response
Testing on the develop branch
I have not tested against the develop branch
Code of Conduct
Detailed steps on how to reproduce the bug
When compiled as a standalone app on OSX with juce 8.0.12, TextEditor set inside a PopupMenu::CustomComponent are not editable. On linux and windows and even on OSX as a plugin it works but standalone its impossible to edit the text.
By using a subclass of TextEditor and some other code to make sure that the PopupMenu doesn't close too fast, I'm able to see that clicks are registered, the location of the caret changes but keyPressed is never called. onReturnKey is never called either.
Here is some code to reproduce the issue. I have reproduced it with a projucer GUI template and the following code:
Custom popupmenu h file:
custom popupmenu cpp file:
main component h file
main component cpp file
What is the expected behaviour?
The value of the texteditor should be editable with the keyboard
Operating systems
macOS
What versions of the operating systems?
Tahoe 26.2
Architectures
Arm64/aarch64
Stacktrace
Plug-in formats (if applicable)
Standalone
Plug-in host applications (DAWs) (if applicable)
No response
Testing on the
developbranchI have not tested against the
developbranchCode of Conduct