JUCEApplication and ActionListener


class JUCE_API JUCEApplication : public ApplicationCommandTarget, private ActionListener

JUCEApplication inherits private ActionListener, which prevents adding my JuceApplication subclass object as an ActionListener. Is that intended ?

I had changed it to protected, to get around it.


I wouldn’t really encourage using any kind of inheritance in your application class. Keep it simple, and just use it as a launching pad for creating and deleting the objects that do the real work in your app.


That makes sense. I’ll see if I can avoid sub-classing.

I’m still a bit confused by the documentation. What’s the point of overriding JUCEApplication::actionListenerCallback if I can’t add the sub-class as a listener ?

[quote]void JUCEApplication::actionListenerCallback ( const String & message ) [virtual]
Overridden by your subclass to receive the callback.[/quote]

I guess if I do override JUCEApplication::actionListenerCallback, I should call the base class first.

The motivation for adding the ActionListener was to allow the user to quit the application by clicking the close window button in an a-synchronic way. The window will send an action to the application, which will call systemRequestedQuit(). There might be a better way to do it.


Ah, that’s just doxygen trying to be helpful, but ending up being confusing. If you look in the actual JUCEApplication header file, the method is just marked “internal”, but doxygen has replaced its comment with the text from the original parent class.

(TBH I should probably use a pimpl to hide that actionlistener callback, and keep the JUCEApplication class nice and clean…)