a button that can remain in one of its two states until its current state is changed by user (either from script or from page):
The addButtonTwoState method should be used to add a new buttonTwoState:
myToolbar.addButtonTwoState(id, pos, text, imgEnabled, imgDisabled);
The user should pass a number of parameters to this method:
- id - id of the new button;
- pos - position of the new button;
- text - button's label;
- imgEnabled - path to image for the enabled state of a new button;
- imgDisabled - path to image for the disabled state of a new button.
Note: if the user wants the buttonTwoState to be created text-free, it's necessary to write an empty string as text parameter.
Related sample: ButtonTwoState creation
Working with ButtonTwoState
The following methods that are available for the Button item, can be applied to the buttonTwoState item as well:
Related sample: ButtonTwoState manipulation
Related sample: ButtonTwoState state
Setting/Getting ButtonTwoState Text
- myToolbar.setItemText(id, text);
Related sample: ButtonTwoState text
Manipulating ButtonTwoState Images
- myToolbar.setItemImage(id, url);
- myToolbar.setItemImageDis(id, url);
Related sample: ButtonTwoState image
Setting/Getting ButtonTwoState Tooltip
Related sample: ButtonTwoState tooltip
All the parameters of the above mentioned methods are the same as those described in the Button Settings Manipulations section.
Setting State of ButtonTwoState
The user can set one of two states for ButtonTwoState with the help of the following method:
myToolbar.setItemState(id, state, callEvent);
The parameters for this method are the following:
- id - id of the two-state button;
- state - true/false, true stands for the Pressed state of the button, false stands for the Released state of the button;
- callEvent - if set to true, calls user defined handler for the onStateChange event (if there is any).
There is also the possibility to get current item's state by calling the getItemState method:
var isPressed = myToolbar.getItemState(id); // returns true/false
The method returns true in case the button is pressed, and false in case the button is released.
Back to top