eSWT components use the predefined touch implementation provided by the device, so you do not need to separately program touch interaction for them. The device platform defines how these components look and behave.
For Controls
, you can implement custom touch
functionality on top of the default functionality by receiving and
handling mouse events. Symbian devices support the following mouse
event methods for notifying about touch events:
The MouseListener.mouseDown
method is called
on touch down events ("mouse button is pressed").
The MouseListener.mouseUp
method is called on
touch release events ("mouse button is released").
The MouseMoveListener.mouseMove
method is called
on drag events ("mouse moves").
For more information about the different event combinations that make up touch actions, see table Basic touch actions.
To implement custom touch functionality
for a Control
:
Use the Screen.isTouchScreen
method to check whether
the device supports touch events. The method returns true
if the device has a touch screen.
Implement the necessary mouse event listeners and methods:
For receiving touch down or touch release events, implement MouseListener
.
For receiving drag events, implement MouseMoveListener
.
Handle the touch events directly in the mouse event methods, or use the methods to call separately defined event handlers.
Register the
listeners for the Control
:
To register the MouseListener
, use the Control.addMouseListener
method.
To register the MouseMoveListener
, use the Control.addMouseMoveListener
method.
The following eSWT components send a widgetDefaultSelected
event when selected:
On S60 5th Edition devices, a component is selected when it
is tapped while focused. From Symbian^3 onwards, a component is selected
with a single tap. The widgetDefaultSelected
event
is sent at the end of the activating tap when touch is released.
The above components also send a widgetSelected
event on the first tap if the selected item has changed. The widgetSelected
event is sent when the screen is touched.
On S60 5th Edition devices, Commands
and Menus
attached to a Control
, including those of any parent Composite
, are shown in the Options menu when the Control
is focused.
From Symbian^3
onwards, Commands
and Menus
attached
to a Control
are shown in a pop-up menu, which is
opened by long-tapping the Control
. The pop-up menu
does not contain the Commands
and Menus
of any parent Composite
. This means that Commands
and Menus
attached to a Composite
are inaccessible if the Composite
area in the UI is fully covered by child Controls
. (The Composite
pop-up menu cannot be long-tapped,
since it is hidden under the child Controls
.)
Note: Use Control
-specific Commands
and Menus
sparingly, since they can be hard to
find with long taps.
Commands
and Menus
attached to Shells
are shown in the Options menu.