What is the correct way to handle mouseDown (or Up) in a derived Component?


Some Components implement their own mouseDown() etc, and some don't.  

There is a generic 'MouseListener', which I have subclassed in my app, and through it handle all hte mouseDown etc for my derived Components.  But I get crashing behavior in some cases (OS X and the ComboBox for instance).

All I want to do is to pass on the mouse events to my code, and in general it does work; except when it doesn't.

Is there some specific manner in which this should be done?


It depends on what you're trying to do but the typical approach for various widgets is to use the provided listener to handle the applicable events.  For instance the combo box has a ComboBox::Listener which will call comboBoxChanged when the selection changes.  So whoever owns the combo box (e.g. the parent component) would inherit from ComboBox::Listener, implement comboBoxChanged and add itself to the child combo box using addListener.

It's not really an issue to add a MouseListener to a widget but it would likely only be done for extraordinary purposes.