Custom MouseListener

Hi There,


No doubt the problem I am having is due to my lack of experience with JUCE framework but here goes:


I am trying create a custom MouseListener for the PluginEditor, so that when a mouse event is detected within the editor window the "hello world" string is changed to "hello mouse" to test that it works.

The ProjectJuceAudioProcessorEditor constructor is as follows:

ProjectJuceAudioProcessorEditor::ProjectJuceAudioProcessorEditor(ProjectJuceAudioProcessorEditor *ownerFilter) : AudioProcessorEditor(ownerFilter){
    setSize(400,300);    // Set window size
    str = "hello world"; // String to be drawn by g.drawFittedText(str, ...,) in paint()
    this->addMouseListener(new PluginEditorMouseListener(&str), true); // Adding Custom Event Listener to the PluginEditor

The PluginEditorMouseListener nested class is defined within ProjectJuceAudioProcessorEditor definition as follows:

class PluginEditorMouseListener : public MouseListener {

       // Pointer to str object above so that its value can be changed in the listener
       std::string *strPtr; 

       // Constructor to point the string pointer at the external string object
       PluginEditorMouseListener (std::string *sp) : MouseListener() {
           strPtr = sp;
       // Overriden version of mouseMoved (when mouseMoved within editor str 
       // should change from "hello world" to "hello mouse"
       virtual void mouseMoved(const MouseEvent &event){
           *strPtr = "hello mouse";

It compiles fine but I don't see any change in the "hello world" string when the mouse is moved within the editor. 

Is this the advised method of doing this or am I going about it incorrectly?





Edit: Apologies "mouseMouse" was meant to be "mouseMoved"


void mouseMouse(const MouseEvent &event)


Apologies "mouseMouse" was meant to be "mouseMoved" -> it was a typo on this post not in my original code

Do you repaint your component when your string changes?

Best if you create custom components, seems a better approach for juce, at least for me.

class ListenerLabel : public Label
        ListenerLabel ()
        void onMouseDown (const MouseEvent &event)
            setText(someText, dontSendNotification);
        void setText(const String &stringToSet)
            someText = stringToSet;
        String someText;