Table Button

SMDialog button: the most basic component.

Summary

FieldTypeSummary
BottomnumberBottom edge of the button, relative to dialog.AreaTop.
Don't change it after creation.
CaptionstringText of the button, can be nil or "" to remove caption
CaptionAllowOverflowboolAllow overflow of caption outside area of the buttons (true by default)?
CaptionAutoLineBreakboolSplit button's caption into lines to try to avoid horizontal overflow (false by default)?
CaptionFaceintFont face, sum of constants FACE_* from MSDefine
CaptionHorizontalAlignintCaption horizontal alignment, centered by default.
CaptionSizeintFont size of the caption
CaptionVerticalAlignintCaption vertical alignment, default is middle.
HelpstringContextual help when button is under mouse pointer.
IsDisabledboolIs button disabled?
IsFocusableboolIs button focusable?
IsFramedboolDraw "palette button" background (default is true)?
IsSelectedboolDisplay the "palette button" look like the selected tool of a palette?
IsVisibleboolVisibility of the button (default=true).
LeftnumberLeft edge of the button, relative to dialog.AreaLeft.
Don't change it after creation.
MouseCursorShapeintCursor shape when mouse pointer is in button's area.
NamestringName of the button.
NextstringNext button (in creation order).
PaddingBottomnumberSpace between bottom edge and caption (default=1)
PaddingLeftnumberSpace between left edge and caption (default=1)
PaddingRightnumberSpace between right edge and caption (default=1)
PaddingTopnumberSpace between top edge and caption (default=1)
PanelstringName of the panel contaning the button.
PreviousstringPrevious button (in creation order).
RightnumberRight edge of the button, relative to dialog.AreaLeft.
Don't change it after creation.
TopnumberTop edge of the button, relative to dialog.AreaTop.
Don't change it after creation.
Return typeFunction and summary
 OnClick(Dialog dialog, Button btn, int x, int y, int click)
Function fired when mouse button is pressed.
 OnClickRelease(Dialog dialog, Button btn, int x, int y, int click)
Function fired when mouse button is released, or focused button receive Space or Enter key.
 OnDraw(Dialog dialog, Button btn)
Fuction called each time the button is drawn, after drawing the bacgkground palette button and the caption.
 OnIdle(Dialog dialog, Button btn)
Function fired each time the dialog window is idle.
boolOnKeyDown(Dialog dialog, dummy, int key, Button btn, bool ctrl, bool shift)
Function fired when button is focused and key strokes are down.
 OnMouseEnter(Dialog dialog, Button btn)
Function fired when mouse enter the button's area.
 OnMouseLeave(Dialog dialog, Button btn)
Function fired when mouse exit the button's area
boolOnMouseMove(Dialog dialog, Button btn, int x, int y, int click)
Function fired each time mouse pointer move within the button's area.
boolOnMouseOver(Dialog dialog, Button btn, int x, int y, int click)
Function fired each time the dialog is idle and mouse pointer is in button's area, even not moving.
 OnMouseWheel(Dialog dialog, Score score, number amount, Button btn)
Function fired when mouse wheel is scrolling while mouse pointer is in button's area.

Fields

string Button.Name

Name of the button.

Don't change it after creation

number Button.Left

Left edge of the button, relative to dialog.AreaLeft.
Don't change it after creation.

You can move its parent panel.

number Button.Top

Top edge of the button, relative to dialog.AreaTop.
Don't change it after creation.

You can move its parent panel.

number Button.Right

Right edge of the button, relative to dialog.AreaLeft.
Don't change it after creation.

You can move its parent panel.

number Button.Bottom

Bottom edge of the button, relative to dialog.AreaTop.
Don't change it after creation.

You can move its parent panel.

string Button.Panel

Name of the panel contaning the button.

Don't change it after creation.

string Button.Caption

Text of the button, can be nil or "" to remove caption

int Button.CaptionSize

Font size of the caption

int Button.CaptionFace

Font face, sum of constants FACE_* from MSDefine

int Button.CaptionHorizontalAlign

Caption horizontal alignment, centered by default.

Possible values are ALIGN_LEFT, ALIGN_RIGHT and ALIGN_CENTER (the default).

bool Button.CaptionAutoLineBreak

Split button's caption into lines to try to avoid horizontal overflow (false by default)?

bool Button.CaptionAllowOverflow

Allow overflow of caption outside area of the buttons (true by default)?

If true, you don't have surprise while developping such as button without caption.

int Button.CaptionVerticalAlign

Caption vertical alignment, default is middle.

Possible values are VERTICAL_ALIGN_TOP, VERTICAL_ALIGN_BOTTOM and VERTICAL_ALIGN_MIDDLE (the default).

string Button.Help

Contextual help when button is under mouse pointer.

number Button.PaddingLeft

Space between left edge and caption (default=1)

number Button.PaddingTop

Space between top edge and caption (default=1)

number Button.PaddingRight

Space between right edge and caption (default=1)

number Button.PaddingBottom

Space between bottom edge and caption (default=1)

bool Button.IsVisible

Visibility of the button (default=true).

Turn it false to hide the button and disable all its events.
Note that you can show/hide all buttons of a Panel with hidePanel(...) and showPanel(...) functions.

bool Button.IsFramed

Draw "palette button" background (default is true)?


If false, it graphically creates a static text, but it can still receive events.
By removing the background and caption, you can display an image file (png, jpg, pct...) in Button.OnDraw(...) event.

bool Button.IsSelected

Display the "palette button" look like the selected tool of a palette?

Toggle it true/false to change button's color.

bool Button.IsDisabled

Is button disabled?

Turn it to true to disable events and change caption color. Button is still visible.

int Button.MouseCursorShape

Cursor shape when mouse pointer is in button's area.

(default=nil) To find the possibles values in MyrScript documentation, write "MouseCursorShape" in your script, and right click ;)

bool Button.IsFocusable

Is button focusable?

(default=true) If focusable, user can place the focus on this button, using Tab or Shift+Tab and then fire Button.OnKeyDown event each time a key is pressed while button is focused.

string Button.Previous

Previous button (in creation order).

Quickly navigate between buttons in descending order.
Readable only, if nil, then this button is the first.

string Button.Next

Next button (in creation order).

Quickly navigate between buttons in creation order.
Readable only, if nil, then this button is the last.

Functions

Button.OnClick(Dialog dialog, Button btn, int x, int y, int click)

Function fired when mouse button is pressed.

ParameterTypeDefaultDescription
dialogDialog The MyrScript Dialog object
btnButton The clicked button
xint The X position of pointer (relative to dialog.AreaLeft)
yint The Y position of pointer (relative to dialog.AreaTop)
clickint The click constant: LEFT_CLICK, RIGHT_CLICK or DUAL_CLICK

Button.OnClickRelease(Dialog dialog, Button btn, int x, int y, int click)

Function fired when mouse button is released, or focused button receive Space or Enter key.

ParameterTypeDefaultDescription
dialogDialog The MyrScript Dialog object
btnButton The clicked button
xint The X position of pointer (relative to dialog.AreaLeft)
yint The Y position of pointer (relative to dialog.AreaTop)
clickint The click constant: LEFT_CLICK, RIGHT_CLICK or DUAL_CLICK

Button.OnKeyDown(Dialog dialog, dummy, int key, Button btn, bool ctrl, bool shift)

Function fired when button is focused and key strokes are down.

Note that if a key is pressed down for a while, this function will be called many times!

ParameterTypeDefaultDescription
dialogDialog The MyrScript Dialog object
dummy  I really don't know what this parameter is!
keyint The pressed key.
btnButton The focused button whose OnKeyDown is fired
ctrlbool Is Ctrl key pressed? Application.IsKeyCodePressed(55)
shiftbool Is Shift key pressed? Application.IsKeyCodePressed(56)
Return
bool: false to stop processing the key, true to continue

Button.OnMouseEnter(Dialog dialog, Button btn)

Function fired when mouse enter the button's area.

ParameterTypeDefaultDescription
dialogDialog The MyrScript Dialog object
btnButton The button mouse pointer just entered

Button.OnMouseLeave(Dialog dialog, Button btn)

Function fired when mouse exit the button's area

ParameterTypeDefaultDescription
dialogDialog The MyrScript Dialog object
btnButton The button mouse pointer just exit

Button.OnMouseMove(Dialog dialog, Button btn, int x, int y, int click)

Function fired each time mouse pointer move within the button's area.

This is less common event, but can be used for a Slider (cursor) while a mouse button is pressed.

ParameterTypeDefaultDescription
dialogDialog The MyrScript Dialog object
btnButton The button under mouse pointer
xint The X position of pointer (relative to dialog.AreaLeft)
yint The Y position of pointer (relative to dialog.AreaTop)
clickint The state of mouse buttons. One of the constant: CLICK_NONE, LEFT_CLICK, RIGHT_CLICK or DUAL_CLICK.
Return
bool: nil or true to redraw the button, false if not needed.

Button.OnMouseOver(Dialog dialog, Button btn, int x, int y, int click)

Function fired each time the dialog is idle and mouse pointer is in button's area, even not moving.

Really uncommon but why not? It can scroll a long caption or play a little animation.

ParameterTypeDefaultDescription
dialogDialog The MyrScript Dialog object
btnButton The button under mouse pointer
xint The X position of pointer (relative to dialog.AreaLeft)
yint The Y position of pointer (relative to dialog.AreaTop)
clickint The state of mouse buttons. One of the constant: CLICK_NONE, LEFT_CLICK, RIGHT_CLICK or DUAL_CLICK.
Return
bool: nil or true to redraw the button, false if not needed.

Button.OnMouseWheel(Dialog dialog, Score score, number amount, Button btn)

Function fired when mouse wheel is scrolling while mouse pointer is in button's area.

Note that in debug mode, mouse wheel is not fired.

ParameterTypeDefaultDescription
dialogDialog The MyrScript Dialog object
scoreScore The front score (I suppose)
amountnumber Sign of amount is used to detect the direction of the wheel.
btnButton The button under mouse pointer

Button.OnDraw(Dialog dialog, Button btn)

Fuction called each time the button is drawn, after drawing the bacgkground palette button and the caption.

This allow to add picture, polygons, draw a complex component. See Slider and Grid.

ParameterTypeDefaultDescription
dialogDialog The MyrScript Dialog object
btnButton The button to draw

Button.OnIdle(Dialog dialog, Button btn)

Function fired each time the dialog window is idle.

This may be used to display a little animation (but time between "frames" may vary!).
This is more useful to detect a change (new score focused, a Slider's value changed programmatically...) to refresh button or component.
Note: use with care and no time consuming operations, as it would impact the user experience, slow GUI response.

ParameterTypeDefaultDescription
dialogDialog The MyrScript Dialog object
btnButton The button to draw