Time for action – responding to the user
When the user clicks on the icon, nothing happens. That's because there is no registered listener on the TrayItem
itself. There are two listeners that can be registered; a SelectionListener
, called when the icon is clicked, and a MenuDetectListener
, which can respond to a context-sensitive menu. The former will be used to present a clock in its own window, which in SWT terms is called a Shell
.
- Open the
Activator
class. - Go to the lambda inside the
asyncExec
in theActivator
class'sstart
method. - After the creation of the
TrayItem
, calladdSelectionListener
with a new anonymous inner subclass ofSelectionListener
. In thewidgetSelected
method, anew Shell
should be created with aClockView
and then shown:trayItem.addSelectionListener(new ...
Get Eclipse Plug-in Development Beginner's Guide - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.