| | | | Browse by category |
Question
How do I set a select interactor to a network?
Answer
There are several ways to set a select interactor to a network.
- Using the configuration file
You can configure the toolbar to contain the select interactor button,through CSS in the following way:
Network {
interactor: true;
toolbar: true;
...
}
ToolBar {
enabled: true;
button[0]: @+SelectButton;
...
}
#SelectButton {
actionType: "Select";
//Adjusting bean properties of interactor...
usingObjectInteractor: true;
opaqueMove: true;
...
}
...Then you can also set the select interactor as the default view interactor in the network, as follows:
Interactor {
name: "Select";
}
- Using the predefined interactors
Some interactors are recognized by their name. You can use the method
setDefaultViewInteractorName
with the string"Select"
as parameter, in the following way:
network.getView().setDefaultViewInteractorName("Select");
- Using the class
IltSelectInteractor
This alternative can be useful when you want to customize your select interactor, that is, when you need to work with an instance of the class
IltSelectInteractor
.
To add anIltSelectInteractor
through the API, you must create an instance of the classIlpViewsViewInteractor
with the select interactor as parameter in the constructor of this class. Then, you can set this view interactor to the network.
The following code extract illustrates this alternative:IltSelectInteractor selInteractor = new IltSelectInteractor();
selInteractor.setMoveAllowed(false);
IlpViewsViewInteractor graphicViewsInteractor =
new IlpViewsViewInteractor(selInteractor);
network.setViewInteractor(viewsInteractor);