Problem with MouseEvent



I’ve been working for a few years with Java so the event concept of Juice immediately seemed familiar to me. I’ve written a small program with a few buttons and a few Components (which show some graphic). Although my application can smoothly receive button clicks, I’m now stuck with receiving mouse clicks.

Here are the most important extracts of my code:

// ApplicationMain.h
// This is the main application file

class ApplicationMain : public JUCEApplication
		void initialise(const String& commandLine);
		void shutdown();
		// More methods here...

		MainWindow* mainWindow;
// MainWindow.h
// This is the main window

class MainWindow  : public DialogWindow
		// More methods here...

		WindowContentComponent* contentComponent;
// WindowContentComponent.h
// This is the content component of the main window.

class WindowContentComponent : public Component, public ButtonListener
		void buttonClicked(Button* button);
		void mouseDown(MouseEvent& event);
		void addToLog(String text);

		// Some attributes here...
// WindowContentComponent.cpp
// Implementation of the content component of the main window.

void WindowContentComponent::mouseDown(MouseEvent& event)
	MainWindow::alert("Test", "Hello world!");
	// alert() is a static user-defined method which simply open an alert window

This code should open an alert window with the caption “Test” and the text “Hello world”, but it doesn’t do this for some reason. I’ve set a breakpoint to the mouseDown() method to see if it’s invoked at all, but it is never invoked when clicking somewhere in the content component (= the entire window content). I’ve also tried to put the mouseDown() method into the MainWindow class (instead of the WindowContentComponent class) with no luck either.

Can anybody point me to the right directon? I’d greatly appreciate your help, because I think Juce is great, and I would like to use it for further development.

Thank you


the function signature of your ButtonListener is wrong, it should be a const reference :

That’s why it doesn’t get called.


the function signature of your ButtonListener is wrong, it should be a const reference :

That’s why it doesn’t get called.[/quote]

Brilliant! That’s it. Thank you so much. It’s really frightening that a single missing keyword was the problem. :slight_smile: