GMMultiButton:
Filter:
GraphicalModule/Classes (extension) | GUI > Graphical Module

GMMultiButton
ExtensionExtension

A simple multi states button for creating graphical interfaces

Description

GMMultiButton is an easy to use customisable button.

It allows to chose between multiple states.

It does not discriminate button identifiers.

ALT modifier

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).

SVG

Specifying a \svg key with a path to a svg file when declaring the states allows to add a custom drawing to the button :

onResize and onClose

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 :

Class Methods

.new

Creates a new instance of GMMultiButton.

Its graphical properties are defined by its associated GMStyle.

Returns:

a GMMultiButton instance.

Instance Methods

Interaction

.action

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.

Arguments:

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).

.mouseDownAction

Equivalent to .action.

.mouseMoveAction

Equivalent to .action.

.states

Sets or gets the View states array, and refreshes the View. Resets the current index to 0.

Arguments:

anArray

An Array. By default, this method is expecting an array filled with dictionaries, each containing a \string, a \color and a \fontColor values. This allows to make the differents buttons easier to distinguish. It is also possible to pass an array of strings as arguments. In this case, the GMStyle backgroundColor and valueFontColor parameters will be used.

.state

Sets or gets the View current selected index.

.allowRetrigger

Sets or gets wether the action should be evaluated again it the selected button is pressed down again.

.allowMouseMove

Sets or gets wether moving the mouse while the multibutton is pressed down should update its state.

.free

Frees the svg files currently used by the view.

Graphical settings

.orientation

Sets the View direction. The View will be distributed horizontally if set as \horizontal, vertically otherwise.

.desindex

Sets the button state equal to -1, which will display the multibutton as if no button was selected.

.direction

Sets or gets the direction of the displayed strings. Valid values are : \right, \top, \left and \bottom.

.drawSelected

Sets or gets whether the selected button should be highlighted.

.fontRatio

Sets or gets the font ratio relative to the height of its case size.

.unselectedRatio

Sets or gets the ratio of unselected buttons. If this value is less than one, they'll be smaller than the selected button.

.setColorAll

Sets the background color of every widget at once, when they are unselected.

.setFontColorAll

Sets the font color of every widget at once, when they are unselected.

.displayAltValue

Sets or gets wether the stored value should be highlighted when using the ALT key modifier. The color used is the GMStyle secondColor parameter.

.svgRatio

Sets or gets the svg ratio relative to the height of its case size.

Internal Methods

.draw

The function associated to the View's drawFunc. Shouldn't be modified

.prResizeSVGs

Examples

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 :