Table Component
SMDialog components: buttons, label, slider, grid...
Summary
Field | Type | Summary |
---|---|---|
A11yCaption | string | Accessible caption, for accessibility (a11y) device, by default, the caption. |
A11yFocus | function | Focus accessibility message |
AllowEnterKey | boolean | Accepts Enter key as click? |
Bottom | number | Bottom edge of the component, relative to dialog.AreaTop .Don't change it after creation. |
Caption | string | Caption of the component, can be nil or "" to remove caption |
CaptionAllowOverflow | boolean | Allow overflow of caption outside area of the component (true by default)? |
CaptionAutoLineBreak | boolean | Split caption into lines to try to avoid horizontal overflow (false by default)? |
CaptionColor | string | Caption (text) color, default is black |
CaptionFace | int | Font face, sum of constants FACE_* from MSDefine |
CaptionHeight | number | Calculated height of the caption, once displayed. |
CaptionHorizontalAlign | int | Caption horizontal alignment, centered by default. |
CaptionSize | int | Font size of the caption |
CaptionVerticalAlign | int | Caption vertical alignment, default is middle. |
CaptionWidth | number | Calculated with of the caption, once displayed. |
DisabledCaptionColor | string | Disabled caption and texts color, default is grey ("888888") |
Help | string | Contextual help when component is under mouse pointer. |
HighlightOnFocus | int | Highlight on focus? |
IsDisabled | boolean | Is button disabled? |
IsFocusable | boolean | Is component focusable? |
IsFramed | boolean | Draw "palette button" background (default is true )? |
IsSelected | boolean | Display the "palette button" look like the selected tool of a palette? |
IsVisible | boolean | Visibility of the component (default=true). |
KeyboardShortcut | string | Keyboard shortcut to focus and click the component. |
Left | number | Left edge of the component, relative to dialog.AreaLeft .Don't change it after creation. |
MidiChannelShortcut | int | Midi channel completing CC# that focus the component and call OnMidiController if exist. |
MidiControllerShortcut | int | Midi CC# that focus the component and call OnMidiController if exist. |
MouseCursorShape | int | Cursor shape when mouse pointer is in component's area. |
Name | string | Name of the component. |
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 containing the component. |
Right | number | Right edge of the component, relative to dialog.AreaLeft .Don't change it after creation. |
Top | number | Top edge of the component, relative to dialog.AreaTop .Don't change it after creation. |
Return type | Function and summary |
---|---|
OnClick(Dialog dlg, Component compo, int x, int y, int click) Function fired when mouse button is pressed. | |
OnClickRelease(Dialog dlg, Component compo, int x, int y, int click) Function fired when mouse button is released, or focused button receive Space or Enter key. | |
OnDraw(Dialog dlg, Component compo) Function called each time the component is drawn, after drawing the bacgkground palette button and the caption. | |
OnExit(Dialog dlg, Component compo) Function fired at Dialog.Exit. | |
OnIdle(Dialog dlg, Component compo) Function fired each time the dialog window is idle. | |
OnInit(Dialog dlg, Component compo) Function fired after Dialog.Init. | |
boolean | OnKeyDown(Dialog dlg, dummy, int key, Component compo, boolean ctrl, boolean shift, string keyAsString) Function fired when button is focused and key strokes are down. |
boolean | OnMidiController(Dialog dlg, Component compo, int channel, int controller, int value) Function fired when a controller from Midi device is moved while mouse pointer is in component's area or component is focused. |
boolean | OnMidiEvent(Dialog dlg, Component compo, int event, int channel, int pitch, int velocity, int timeMs, number timePos, int source) Function fired when a Midi event is received from Midi or virtual device, while mouse pointer is in component's area or component is focused. |
boolean | OnMidiNoteOff(Dialog dlg, Component compo, int channel, int pitch, int velocity) Function fired when a note is released on Midi or virtual input, while mouse pointer is in component's area or component is focused. |
boolean | OnMidiNoteOn(Dialog dlg, Component compo, int channel, int pitch, int velocity) Function fired when a note is pressed on Midi or virtual input, while mouse pointer is in component's area or component is focused. |
boolean | OnMidiPitchBend(Dialog dlg, Component compo, int channel, int value) Function fired when the pitch bend wheel of Midi device is moved, while mouse pointer is in component's area or component is focused. |
OnMouseEnter(Dialog dlg, Component compo) Function fired when mouse enter the button's area. | |
OnMouseLeave(Dialog dlg, Component compo) Function fired when mouse exit the button's area | |
boolean | OnMouseMove(Dialog dlg, Component compo, int x, int y, int click) Function fired each time mouse pointer move within the button's area. |
boolean | OnMouseOver(Dialog dlg, Component compo, 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 dlg, Score score, number amount, Component compo) Function fired when mouse wheel is scrolling while mouse pointer is in component's area. |
Fields
number Component.Left
Left edge of the component, relative to dialog.AreaLeft
.
Don't change it after creation.
You can move its parent panel.
number Component.Top
Top edge of the component, relative to dialog.AreaTop
.
Don't change it after creation.
You can move its parent panel.
number Component.Right
Right edge of the component, relative to dialog.AreaLeft
.
Don't change it after creation.
You can move its parent panel.
number Component.Bottom
Bottom edge of the component, relative to dialog.AreaTop
.
Don't change it after creation.
You can move its parent panel.
string Component.Caption
Caption of the component, can be nil
or ""
to remove caption
string Component.A11yCaption
Accessible caption, for accessibility (a11y) device, by default, the caption.
int Component.CaptionSize
Font size of the caption
string Component.CaptionColor
Caption (text) color, default is black
string Component.DisabledCaptionColor
Disabled caption and texts color, default is grey ("888888")
int Component.CaptionFace
Font face, sum of constants FACE_* from MSDefine
int Component.CaptionHorizontalAlign
Caption horizontal alignment, centered by default.
Possible values are ALIGN_LEFT, ALIGN_RIGHT and ALIGN_CENTER (the default).
boolean Component.CaptionAutoLineBreak
Split caption into lines to try to avoid horizontal overflow (false
by default)?
boolean Component.CaptionAllowOverflow
Allow overflow of caption outside area of the component (true
by default)?
If true
, you don't have surprise while developping such as component without caption.
int Component.CaptionVerticalAlign
Caption vertical alignment, default is middle.
Possible values are VERTICAL_ALIGN_TOP, VERTICAL_ALIGN_BOTTOM and VERTICAL_ALIGN_MIDDLE (the default).
string Component.Help
Contextual help when component is under mouse pointer.
number Component.PaddingLeft
Space between left edge and caption (default=1)
number Component.PaddingTop
Space between top edge and caption (default=1)
number Component.PaddingRight
Space between right edge and caption (default=1)
number Component.PaddingBottom
Space between bottom edge and caption (default=1)
boolean Component.IsVisible
Visibility of the component (default=true).
Turn it false
to hide the component and disable all its events.
Note that you can show/hide all components of a Panel with hidePanel(...)
and showPanel(...)
functions.
boolean Component.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.
boolean Component.IsSelected
Display the "palette button" look like the selected tool of a palette?
Toggle it true/false to change background color.
boolean Component.IsDisabled
Is button disabled?
Turn it to true
to disable events and change caption color. Component is still visible.
int Component.MouseCursorShape
Cursor shape when mouse pointer is in component's area.
(default=nil
) To find the possibles values in MyrScript documentation, write "MouseCursorShape" in your script, and right click ;)
boolean Component.IsFocusable
Is component focusable?
(default=true) If focusable, user can place the focus on this component, by a click, or Tab or Shift+Tab or assigned shortcut, and then fire Component.OnKeyDown
event each time a key is pressed while component is focused.
int Component.HighlightOnFocus
Highlight on focus?
4 possible highlight mode for focused Component, so user see which component will receive key strokes.
FOCUS_HIGHLIGHT_FULL
, by default: paint a half-transparent colored rectangle over the component,FOCUS_HIGHLIGHT_FRAME
, draw a colored frame around the component,FOCUS_HIGHLIGHT_CAPTION
, change the caption text color,FOCUS_HIGHLIGHT_NONE
, no highlight, probably handled by component'sOnDraw(...)
event.
string Component.KeyboardShortcut
Keyboard shortcut to focus and click the component.
- This is a string like
"X", "Ctrl+X", "Ctrl+Shift+X", "Shift+X"
. - Both left and right Shift are handled in the same way: no distinction between left and right.
- Alt key is not handled, MyrScript limitation.
- Alphanumerics are sure, punctuations may be less user friendly (different keyboard layout in other countries),
- Use
"F1"
to"F12"
at your own risk. - No special keys like Space, Tab, Esc, BackSpace, arrows... These are special, used to navigate between components, exit dialog...
boolean Component.AllowEnterKey
Accepts Enter key as click?
If true
(default), Space and Enter will fire OnClick and/or OnClickRelease functions. If false
, only Space fire them. This is good practice for togglable component such as checkboxes, radios and switches. Then the DialogItem (Ok button) with IsDefault = true is pushed.
number Component.CaptionWidth
Calculated with of the caption, once displayed.
number Component.CaptionHeight
Calculated height of the caption, once displayed.
int Component.MidiControllerShortcut
Midi CC# that focus the component and call OnMidiController if exist.
As it is device-dependant, this is not recommand for distributed scripts. To know which channel and controller are assigned to your Midi's buttons, knobs and sliders, launch the script Midi > MIDI input monitor
int Component.MidiChannelShortcut
Midi channel completing CC# that focus the component and call OnMidiController if exist.
As it is device-dependant, this is not recommand for distributed scripts. To know which channel and controller are assigned to your Midi's buttons, knobs and sliders, launch the script Midi > MIDI input monitor
Functions
Component.OnInit(Dialog dlg, Component compo)
Function fired after Dialog.Init.
If it opens resources, close them in OnExit()
Component.OnClick(Dialog dlg, Component compo, int x, int y, int click)
Function fired when mouse button is pressed.
Component.OnClickRelease(Dialog dlg, Component compo, int x, int y, int click)
Function fired when mouse button is released, or focused button receive Space or Enter key.
Component.OnKeyDown(Dialog dlg, dummy, int key, Component compo, boolean ctrl, boolean shift, string keyAsString)
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 |
---|---|---|---|
dlg | Dialog | The MyrScript Dialog object | |
dummy | I really don't know what this parameter is! | ||
key | int | The pressed key code (9 for Tab, 32 for Space, 122 for z) Caution: this may be nil in case of F1 to F12 keys. See keyAsString argument. | |
compo | Component | The focused component whose OnKeyDown is fired | |
ctrl | boolean | Is Ctrl key pressed? Application.IsKeyCodePressed(55) == true | |
shift | boolean | Is Shift key pressed? Application.IsKeyCodePressed(56) == true | |
keyAsString | string | "X", "Ctrl+X", "Ctrl+Shift+X", "Shift+X" |
- Return
- boolean:
false
to stop processing the key,true
to continue
Component.OnMouseEnter(Dialog dlg, Component compo)
Function fired when mouse enter the button's area.
Component.OnMouseLeave(Dialog dlg, Component compo)
Function fired when mouse exit the button's area
Component.OnMouseMove(Dialog dlg, Component compo, 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 |
---|---|---|---|
dlg | Dialog | The MyrScript Dialog object | |
compo | Component | The component 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
- boolean:
nil
ortrue
to redraw the button,false
if not needed.
Component.OnMouseOver(Dialog dlg, Component compo, 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 |
---|---|---|---|
dlg | Dialog | The MyrScript Dialog object | |
compo | Component | The component 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
- boolean:
nil
ortrue
to redraw the button,false
if not needed.
Component.OnMouseWheel(Dialog dlg, Score score, number amount, Component compo)
Function fired when mouse wheel is scrolling while mouse pointer is in component's area.
Note that in debug mode, mouse wheel is not fired.
Component.OnMidiNoteOn(Dialog dlg, Component compo, int channel, int pitch, int velocity)
Function fired when a note is pressed on Midi or virtual input, while mouse pointer is in component's area or component is focused.
Parameter | Type | Default | Description |
---|---|---|---|
dlg | Dialog | The MyrScript Dialog object | |
compo | Component | The component focused or under mouse pointer | |
channel | int | Midi channel, 1 to 16 | |
pitch | int | The note pitch, 0 to 127 | |
velocity | int | The note velocity, from 0 to 127, most probably never 0. |
- Return
- boolean:
nil
ortrue
if event is handled and should not be propagated elsewhere,false
to continue propagation of the Midi 'Note On' event.
Component.OnMidiNoteOff(Dialog dlg, Component compo, int channel, int pitch, int velocity)
Function fired when a note is released on Midi or virtual input, while mouse pointer is in component's area or component is focused.
Parameter | Type | Default | Description |
---|---|---|---|
dlg | Dialog | The MyrScript Dialog object | |
compo | Component | The component focused or under mouse pointer | |
channel | int | Midi channel, 1 to 16 | |
pitch | int | The note pitch, 0 to 127 | |
velocity | int | The release velocity, from 0 to 127, most probably always 0 unless Midi device features aftertouch and release velocity. |
- Return
- boolean:
nil
ortrue
if event is handled and should not be propagated elsewhere,false
to continue propagation of the Midi 'Note Off' event.
Component.OnMidiController(Dialog dlg, Component compo, int channel, int controller, int value)
Function fired when a controller from Midi device is moved while mouse pointer is in component's area or component is focused.
Parameter | Type | Default | Description |
---|---|---|---|
dlg | Dialog | The MyrScript Dialog object | |
compo | Component | The component focused or under mouse pointer | |
channel | int | Midi channel, 1 to 16 | |
controller | int | Midi controller, 0 to 127 | |
value | int | Controller's value, 0 to 127 |
- Return
- boolean:
nil
ortrue
if event is handled and should not be propagated elsewhere,false
to continue propagation of the Midi CC event.
Component.OnMidiPitchBend(Dialog dlg, Component compo, int channel, int value)
Function fired when the pitch bend wheel of Midi device is moved, while mouse pointer is in component's area or component is focused.
If component has no OnMidiPitchBend function but has OnMouseWheel function, then the pitch wheel acts as a mouse wheel: moving down (lowering the pitch) is a scroll down when bend is negative, moving up (rising the pitch) is a scroll up when bend is positive.
Parameter | Type | Default | Description |
---|---|---|---|
dlg | Dialog | The MyrScript Dialog object | |
compo | Component | The component focused or under mouse pointer | |
channel | int | Midi channel, 1 to 16 | |
value | int | Pitch bend value, -8127 to 8128 |
- Return
- boolean:
nil
ortrue
if event is handled and should not be propagated elsewhere,false
to continue propagation of the Midi CC event.
Component.OnMidiEvent(Dialog dlg, Component compo, int event, int channel, int pitch, int velocity, int timeMs, number timePos, int source)
Function fired when a Midi event is received from Midi or virtual device, while mouse pointer is in component's area or component is focused.
Event types depends on SMDialog.MidiAllow* values.
Parameter | Type | Default | Description |
---|---|---|---|
dlg | Dialog | The MyrScript Dialog object | |
compo | Component | The component focused or under mouse pointer | |
event | int | Midi event type:
| |
channel | int | Midi channel, 1 to 16 | |
pitch | int | The note pitch / selected controller / program, from 0 to 127 | |
velocity | int | The velocity / controller value from 0 to 127 | |
timeMs | int | The time position in millisecond of the event | |
timePos | number | The time position in the playing score (-1 if no score currently playing) | |
source | int | The source for this event (MSDefine constant)::
|
- Return
- boolean:
nil
ortrue
if event is handled and should not be propagated elsewhere,false
to continue propagation of the Midi CC event.
Component.OnDraw(Dialog dlg, Component compo)
Function called each time the component 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.
Component.OnIdle(Dialog dlg, Component compo)
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.