I know this sounds like a very basic question, and I feel embarrassed to ask it but...
How to I add a Mouse Click handler to an SWT button?
What I checked:
- I can find tons of examples on how to add mouse down, mouse up or double click handlers (by assigning a MouseListener). Obviously, mouse click (sequence of down and up on the same control) is something different than mouse down.
- I understand that there might not be a click handler on generic controls, but the only event I see added on the Button control is a SelectionListener -- that might be it, but selection sounds more like "received focus" to me than "was clicked or selected and then invoked with a key press".
- I found a related question, whose answer basically says that you need to implement that yourself -- I find that a bit hard to believe.
Is selection what is commonly known as "OnClick" in other languages/frameworks? Or is there something else that I completely missed?
SWT.Selection
orSelectionListener
is what you're looking for. It might be called selection, because aButton
can be a checkbox or a radion button depending on it's style. – Landau