Toolbar.AddToolButtonRequest
Requests for toolbar to add button with given config
Use cases
- Add tool button to toolbar
Description
Requests for the toolbar to add a button with given config.
There are two main types of toolbar buttons: normal buttons & "sticky" buttons. Normal buttons act like any other button in the Oskari UI. Clicking on the button just activates some callback given in the config. Sticky buttons on the other hand stay active (visually pressed down) until some other sticky button is activated. This means that only one sticky button can be active at a time (like radio buttons). It's the responsibility of the functionality adding the button to the toolbar to listen to Toolbar.ToolSelectedEvent
and stop any ongoing mode the tool implements when some other sticky tool is activated. The event has method getSticky()
to check for stickyness of the newly selected tool. When a sticky tool wants to end its functionality (eg. user clicks "Cancel"), it should select the default tool. This can be done by sending Toolbar.SelectToolButtonRequest
without parameters.
Parameters
(* means the parameter is required)
Name | Type | Description | Default value |
---|---|---|---|
\* id | String | Button identifier | |
\* group | String | Group identifier | |
\* config | Object | Button config |
Parameters for config-object:
Name | Type | Description | Default value |
---|---|---|---|
\* iconCls | String | button icon class | |
tooltip | String | button tooltip | |
show | Boolean | show button | true |
disabled | Boolean | add the button in disabled state | false |
callback | Function | button callback function | |
sticky | Boolean | does the button stay active after pressing | false |
activeColour | String | button active background colour | |
toggleChangeIcon | Boolean | toggle change button icon. Is this setted true, icon class is calculated for added activeColour (light/dark) |
Examples
Add button to toolbar:
var sb = Oskari.getSandbox();
var addToolButtonBuilder = sb.getRequestBuilder('Toolbar.AddToolButtonRequest');
var tool = 'ExampleTool';
var group = 'ExampleGroup';
var buttonConf = {
iconCls: 'mobile-zoom-in',
tooltip: '',
sticky: false,
show: true,
callback: function (el) {
alert('Button clicked');
}
};
sb.request('MainMapModule', addToolButtonBuilder(tool, group, buttonConf));