Bug with text input on macOS


The code below demonstrates the problem. If you compile this application and simply run the binary directly, all the text output appears in the console. If you run it from inside a .app Bundle, the text appears in the TextEdit.

#include "JuceHeader.h"
class testcaseApplication  : public JUCEApplication
    testcaseApplication() {}
    const String getApplicationName() override       { return ProjectInfo::projectName; }
    const String getApplicationVersion() override    { return ProjectInfo::versionString; }
    bool moreThanOneInstanceAllowed() override       { return true; }
    DocumentWindow *doc;
    void initialise (const String& commandLine) override
        // Add your application's initialisation code here..
        doc = new DocumentWindow("TestApp", Colour(0xFFFFFFFF), 7);
        doc->setUsingNativeTitleBar (true); 
        doc->setResizable (true, false); 
		TextEditor *text = new TextEditor();
		text->setColour(TextEditor::backgroundColourId, Colour(0xFFFFFFFF));
		text->setColour(TextEditor::textColourId, Colour(0xFF000000));
		doc->setContentOwned(text, true);
    void shutdown() override
        // Add your application's shutdown code here..
    void systemRequestedQuit() override
        // This is called when the app is being asked to quit: you can ignore this
        // request and let the app carry on running, or call quit() to allow the app to close.
    void anotherInstanceStarted (const String& commandLine) override
        // When another instance of the app is launched while this one is running,
        // this method is invoked, and the commandLine parameter tells you what
        // the other instance's command-line arguments were.
// This macro generates the main() routine that launches the app.
START_JUCE_APPLICATION (testcaseApplication)


Apparently none of y’all care, but the solution is to convert the app to a “foreground” one:

ProcessSerialNumber psn;
GetCurrentProcess( &psn );
TransformProcessType(&psn, kProcessTransformToForegroundApplication);

You’re welcome.


What text do you refer to?

In your initialization code, you’re not assigning any text to your TextEditor, and the other methods are basically empty.


Typing text into the TextEditor. That’s it.