Interface IController
IController
implementation interprets received events and triggers an action on the map.
It receives toolkit-independent events (IInputEvent
) and has a LayerList
for controller-specific visualization.
The IController
receives high level event (via IController#onEvent
) from a provider like a MouseGestureRecognizer
and is responsible to create gesture handlers, such a PanEventHandler
or a fully custom one.
You can optionally bind a MouseGestureRecognizer
or a TouchGestureRecognizer
to your controller. You can find example code for this in this tutorial. The tutorial shows how this is done in C++ and for Qt, but the same principle can be applied to other UI frameworks as well.
You can use your own binding code using the following code :
KeyCode key = KeyCode.C;
ModifierKeys modifiers = ModifierKeys.Ctrl;
var keyEvent = new KeyEvent(ButtonState.Pressed, key, modifiers);
controller.onEvent(keyEvent);
If you need to add visual components to the map to respond to user interactions, your controller can implement the IController#getLayerList
method. You use it to return a LayerList
to visualize controller-specific information such as handles.
For more information on controllers in LuciadCPillar, refer to the related guide and article.
-
Method Summary
Modifier and TypeMethodDescriptionReturns the layer list used by the controller if it needs to provide visual component to the map following user interactions.void
onActivate
(Map map) Used by the map to signal that this controller can start interaction with the map.void
onDeactivate
(Map map) Used by the map to signal that this controller is no longer the active controller of a map.void
onEvent
(IInputEvent inputEvent) Entry point of the controller.
-
Method Details
-
onEvent
Entry point of the controller.This method is typically called by the callback of a
MouseGestureRecognizer
or aTouchGestureRecognizer
.- Note
- a casting of the
IInputEvent
will be necessary to access its fields.
- Parameters:
inputEvent
- : a high level event.
-
getLayerList
Returns the layer list used by the controller if it needs to provide visual component to the map following user interactions.The map captures the initial composition of this list when the controller is activated and will listen to its future composition updates.
This layer list is independent from the map layer list and will always be displayed on top.
- Note
- The
LayerList
must not benull
.
- See Also:
-
onActivate
Used by the map to signal that this controller can start interaction with the map.Is called when the controller is activated on a map using
Map#setController
. Once this method is called, you can use the map to create map-dependent objects.- Note
- make sure to either store this shared pointer as a weak pointer or clean the local reference when
IController#onDeactivate
is called.
-
onDeactivate
Used by the map to signal that this controller is no longer the active controller of a map.Is called when the controller is deactivated on a map
Map#setController
or when the map is destroyed. The controller should clean all references to the map when this method is invoked.
-