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

GMRoundButton
ExtensionExtension

A simple round button with a visual feedback effect for creating graphical interfaces

Description

GMRoundButton is an easy to use customisable button with a visual feedback.

On press, its color switches from a second state back to its default state within a defined period of time.

It only responds to mouse down clicks, and does not discriminate button identifiers.

NOTE: Since the .frameRate method inherited from the UserView class is unreliable, the frame rate of this UserView is hardcoded at 60 fps, and changing it will desynchronize the blinkTime value.

Class Methods

.new

Creates a new instance of GMRoundButton.

Its graphical properties are defined by its associated GMStyle.

Both the blink color and the font blink color must be set explicitly.

Returns:

a GMRoundButton instance.

Instance Methods

Interaction

.action

Sets or gets the Function to be triggered when the button is pressed down. Doesn't take argument.

Arguments:

aFunction

A Function without argument.

.mouseDownAction

Sets or gets the Function to be triggered when the button is pressed down. Doesn't take argument. Equivalent to .action .

Arguments:

aFunction

A Function without argument.

Graphical settings

.blink

Triggers the button animation, without evaluating associated function. This method allows to simulate the button being pressed using code. Refresh call is internally deferred, so this method can be called safely within a Routine context.

.blinkColor

Sets or gets the widget back color when it's starting its visual effect.

.blinkFontColor

Sets or gets the widget font color when it's starting its visual effect.

.blinkTime

Sets or gets the time in seconds it takes for the View's to complete its visual effect.

Arguments:

aNumber

A Float value, in seconds.

.string

Sets or gets the button displayed text, and refreshes the View.

.fontRatio

Sets or gets the widget displayed text ratio, relative to the size of the widget (not counting the border size). You'll need to reduce this value if the displayed text is larger than the size of the widget.

.stringRatio

Deprecated, use fontRatio instead.

.maxFontSize

Sets or gets the displayed text max height, in pixels.

.orientation

Sets or gets the button displayed text orientation. Valid values are : \right, \top, \left or \bottom. This doesn't affect the displayed svg if any.

.svg

Sets or gets the button displayed svg, and refreshes the View. Takes a String indicating the path to the svg file as argument.

.svgRatio

Sets or gets the widget displayed svg ratio, relative to the smallest axis of the widget, and refreshes the View.

.free

Removes the svg and frees its ressources. Refreshes the View.

Internal Methods

.draw

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

.resizeSVG

The function that rescales the svg when needed.

Examples