Table Button
SMDialog button: the most basic component.
Summary
Field | Type | Summary |
---|---|---|
Bottom | number | Bottom edge of the button, relative to dialog.AreaTop .Don't change it after creation. |
Caption | string | Text of the button, can be nil or "" to remove caption |
CaptionAllowOverflow | bool | Allow overflow of caption outside area of the buttons (true by default)? |
CaptionAutoLineBreak | bool | Split button's caption into lines to try to avoid horizontal overflow (false by default)? |
CaptionFace | int | Font face, sum of constants FACE_* from MSDefine |
CaptionHorizontalAlign | int | Caption horizontal alignment, centered by default. |
CaptionSize | int | Font size of the caption |
CaptionVerticalAlign | int | Caption vertical alignment, default is middle. |
Help | string | Contextual help when button is under mouse pointer. |
IsDisabled | bool | Is button disabled? |
IsFocusable | bool | Is button focusable? |
IsFramed | bool | Draw "palette button" background (default is true)? |
IsSelected | bool | Display the "palette button" look like the selected tool of a palette? |
IsVisible | bool | Visibility of the button (default=true). |
Left | number | Left edge of the button, relative to dialog.AreaLeft .Don't change it after creation. |
MouseCursorShape | int | Cursor shape when mouse pointer is in button's area. |
Name | string | Name of the button. |
Next | string | Next button (in creation order). |
PaddingBottom | number | Space between bottom edge and caption (default=1) |
PaddingLeft | number | Space between left edge and caption (default=1) |
PaddingRight | number | Space between right edge and caption (default=1) |
PaddingTop | number | Space between top edge and caption (default=1) |
Panel | string | Name of the panel contaning the button. |
Previous | string | Previous button (in creation order). |
Right | number | Right edge of the button, relative to dialog.AreaLeft .Don't change it after creation. |
Top | number | Top edge of the button, relative to dialog.AreaTop .Don't change it after creation. |
Return type | Function 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. | |
bool | OnKeyDown(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 | |
bool | OnMouseMove(Dialog dialog, Button btn, int x, int y, int click) Function fired each time mouse pointer move within the button's area. |
bool | 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. |
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
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.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.
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.
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!
Parameter | Type | Default | Description |
---|---|---|---|
dialog | Dialog | The MyrScript Dialog object | |
dummy | I really don't know what this parameter is! | ||
key | int | The pressed key. | |
btn | Button | The focused button whose OnKeyDown is fired | |
ctrl | bool | Is Ctrl key pressed? Application.IsKeyCodePressed(55) | |
shift | bool | 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.
Button.OnMouseLeave(Dialog dialog, Button btn)
Function fired when mouse exit the button's area
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.
Parameter | Type | Default | Description |
---|---|---|---|
dialog | Dialog | The MyrScript Dialog object | |
btn | Button | The button under mouse pointer | |
x | int | The X position of pointer (relative to dialog.AreaLeft) | |
y | int | The Y position of pointer (relative to dialog.AreaTop) | |
click | int | 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.
Parameter | Type | Default | Description |
---|---|---|---|
dialog | Dialog | The MyrScript Dialog object | |
btn | Button | The button under mouse pointer | |
x | int | The X position of pointer (relative to dialog.AreaLeft) | |
y | int | The Y position of pointer (relative to dialog.AreaTop) | |
click | int | 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.
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.
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.