GMMultiButton is an easy to use customisable button.
It allows to chose between multiple states.
It does not discriminate button identifiers.
When holding ALT while clicking the mouse down, the previous index will be stored. Releasing the mouse button while holding ALT will cause the multibutton to jump back to its stored state (see example below).
Specifying a \svg
key with a path to a svg file when declaring the states allows to add a custom drawing to the button :
Due to the possibility to assign svgs images to the button, the onResize
and onClose
functions of the view are natively modified. Overidding those functions isn't a good idea. Since they've been replaced by FunctionList instances, you can use the addFunc
method to append functions to them instead :
Creates a new instance of GMMultiButton.
Its graphical properties are defined by its associated GMStyle.
a GMMultiButton instance.
Sets or gets the Function to be triggered when the button is pressed. This Function takes the current index of the button as argument, i.e. pressing the first button on the left (or the top if set as vertical) will call the Function passing 0 as argument. Reclicking a previously selected button will call the Function again if the retrigger
parameter has been set to true
.
aFunction |
A Function with one argument, the current index of the button as an Integer. The case control structure allows to easily define what actions it should trigger (see example below). |
Equivalent to .action
.
Equivalent to .action
.
Sets or gets the View states array, and refreshes the View. Resets the current index to 0.
anArray |
An Array. By default, this method is expecting an array filled with dictionaries, each containing a |
Sets or gets the View current selected index.
Sets or gets wether the action
should be evaluated again it the selected button is pressed down again.
Sets or gets wether moving the mouse while the multibutton is pressed down should update its state.
Frees the svg files currently used by the view.
Sets the View direction. The View will be distributed horizontally if set as \horizontal
, vertically otherwise.
Sets the button state equal to -1
, which will display the multibutton as if no button was selected.
Sets or gets the direction of the displayed strings. Valid values are : \right
, \top
, \left
and \bottom
.
Sets or gets whether the selected button should be highlighted.
Sets or gets the font ratio relative to the height of its case size.
Sets or gets the maximum allowed font size, in pixels.
Sets or gets the ratio of unselected buttons. If this value is less than one, they'll be smaller than the selected button.
Sets the background color of every widget at once, when they are unselected.
Sets the font color of every widget at once, when they are unselected.
Sets or gets wether the stored value should be highlighted when using the ALT key modifier. The color used is the GMStyle secondColor
parameter.
Sets or gets the svg ratio relative to the height of its case size.
The function associated to the View's drawFunc
. Shouldn't be modified
Used as a rudimentary keyboard :
When holding the ALT key down, modifying the value by pressing and releasing the mouse button gives a 'live instrument feel' on certain parameters :
GMMultiButton can be used in conjonction with a StackLayout, to display a top menu allowing to switch between several views :