Table Component

SMDialog components: buttons, label, slider, grid...

Summary

FieldTypeSummary
A11yCaptionstringAccessible caption, for accessibility (a11y) device, by default, the caption.
A11yFocusfunctionFocus accessibility message
AllowEnterKeybooleanAccepts Enter key as click?
BottomnumberBottom edge of the component, relative to dialog.AreaTop.
Don't change it after creation.
CaptionstringCaption of the component, can be nil or "" to remove caption
CaptionAllowOverflowbooleanAllow overflow of caption outside area of the component (true by default)?
CaptionAutoLineBreakbooleanSplit caption into lines to try to avoid horizontal overflow (false by default)?
CaptionColorstringCaption (text) color, default is black
CaptionFaceintFont face, sum of constants FACE_* from MSDefine
CaptionHeightnumberCalculated height of the caption, once displayed.
CaptionHorizontalAlignintCaption horizontal alignment, centered by default.
CaptionSizeintFont size of the caption
CaptionVerticalAlignintCaption vertical alignment, default is middle.
CaptionWidthnumberCalculated with of the caption, once displayed.
DisabledCaptionColorstringDisabled caption and texts color, default is grey ("888888")
HelpstringContextual help when component is under mouse pointer.
HighlightOnFocusintHighlight on focus?
IsDisabledbooleanIs button disabled?
IsFocusablebooleanIs component focusable?
IsFramedbooleanDraw "palette button" background (default is true)?
IsSelectedbooleanDisplay the "palette button" look like the selected tool of a palette?
IsVisiblebooleanVisibility of the component (default=true).
KeyboardShortcutstringKeyboard shortcut to focus and click the component.
LeftnumberLeft edge of the component, relative to dialog.AreaLeft.
Don't change it after creation.
MidiChannelShortcutintMidi channel completing CC# that focus the component and call OnMidiController if exist.
MidiControllerShortcutintMidi CC# that focus the component and call OnMidiController if exist.
MouseCursorShapeintCursor shape when mouse pointer is in component's area.
NamestringName of the component.
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 containing the component.
RightnumberRight edge of the component, relative to dialog.AreaLeft.
Don't change it after creation.
TopnumberTop edge of the component, relative to dialog.AreaTop.
Don't change it after creation.
Return typeFunction 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.
booleanOnKeyDown(Dialog dlg, dummy, int key, Component compo, boolean ctrl, boolean shift, string keyAsString)
Function fired when button is focused and key strokes are down.
booleanOnMidiController(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.
booleanOnMidiEvent(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.
booleanOnMidiNoteOff(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.
booleanOnMidiNoteOn(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.
booleanOnMidiPitchBend(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
booleanOnMouseMove(Dialog dlg, Component compo, int x, int y, int click)
Function fired each time mouse pointer move within the button's area.
booleanOnMouseOver(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

string Component.Name

Name of the component.

Don't change it after creation

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

Name of the Panel containing the component.

Don't change it after creation.

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.

function Component.A11yFocus

Focus accessibility message

ParameterTypeDefaultDescription
dlgDialog dlg
compoComponent compo
Return
string: string

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's OnDraw(...) 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()

ParameterTypeDefaultDescription
dlgDialog The MyrScript Dialog object
compoComponent The component to initialize

Component.OnClick(Dialog dlg, Component compo, int x, int y, int click)

Function fired when mouse button is pressed.

ParameterTypeDefaultDescription
dlgDialog The MyrScript Dialog object
compoComponent The clicked component
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

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.

ParameterTypeDefaultDescription
dlgDialog The MyrScript Dialog object
compoComponent The clicked component
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

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!

ParameterTypeDefaultDescription
dlgDialog The MyrScript Dialog object
dummy  I really don't know what this parameter is!
keyint 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.
compoComponent The focused component whose OnKeyDown is fired
ctrlboolean Is Ctrl key pressed? Application.IsKeyCodePressed(55) == true
shiftboolean Is Shift key pressed? Application.IsKeyCodePressed(56) == true
keyAsStringstring "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.

ParameterTypeDefaultDescription
dlgDialog The MyrScript Dialog object
compoComponent The component mouse pointer just entered

Component.OnMouseLeave(Dialog dlg, Component compo)

Function fired when mouse exit the button's area

ParameterTypeDefaultDescription
dlgDialog The MyrScript Dialog object
compoComponent The component mouse pointer just exit

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.

ParameterTypeDefaultDescription
dlgDialog The MyrScript Dialog object
compoComponent The component 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
boolean: nil or true 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.

ParameterTypeDefaultDescription
dlgDialog The MyrScript Dialog object
compoComponent The component 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
boolean: nil or true 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.

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

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.

ParameterTypeDefaultDescription
dlgDialog The MyrScript Dialog object
compoComponent The component focused or under mouse pointer
channelint Midi channel, 1 to 16
pitchint The note pitch, 0 to 127
velocityint The note velocity, from 0 to 127, most probably never 0.
Return
boolean: nil or true 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.

ParameterTypeDefaultDescription
dlgDialog The MyrScript Dialog object
compoComponent The component focused or under mouse pointer
channelint Midi channel, 1 to 16
pitchint The note pitch, 0 to 127
velocityint The release velocity, from 0 to 127, most probably always 0 unless Midi device features aftertouch and release velocity.
Return
boolean: nil or true 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.

ParameterTypeDefaultDescription
dlgDialog The MyrScript Dialog object
compoComponent The component focused or under mouse pointer
channelint Midi channel, 1 to 16
controllerint Midi controller, 0 to 127
valueint Controller's value, 0 to 127
Return
boolean: nil or true 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.

ParameterTypeDefaultDescription
dlgDialog The MyrScript Dialog object
compoComponent The component focused or under mouse pointer
channelint Midi channel, 1 to 16
valueint Pitch bend value, -8127 to 8128
Return
boolean: nil or true 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.

ParameterTypeDefaultDescription
dlgDialog The MyrScript Dialog object
compoComponent The component focused or under mouse pointer
eventint Midi event type:
  • 1 mean note on (key pressed),
  • 2 mean note off or note on with velocity = 0 (key released)
  • 10 means polyphonic aftertouch
  • 11 means CC, Controller Change (modulation wheel, pedal, knobs, cursors, bank change...)
  • 12 means PC, Program Change
  • 13 means channel aftertouch
  • 14 means pitch bend
channelint Midi channel, 1 to 16
pitchint The note pitch / selected controller / program, from 0 to 127
velocityint The velocity / controller value from 0 to 127
timeMsint The time position in millisecond of the event
timePosnumber The time position in the playing score (-1 if no score currently playing)
sourceint The source for this event (MSDefine constant)::
  • INPUT_SOURCE_UNKNOWN: none/unknown
  • INPUT_SOURCE_MIDI: from an external MIDI device
  • INPUT_SOURCE_VIRTUAL_KBD: from a click on a virtual keyboard
  • INPUT_SOURCE_COMPUTER_KBD: from the computer keyboard
  • INPUT_SOURCE_PLAYED_MUSIC: from the played score
Return
boolean: nil or true 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.

ParameterTypeDefaultDescription
dlgDialog The MyrScript Dialog object
compoComponent The component to draw

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.

ParameterTypeDefaultDescription
dlgDialog The MyrScript Dialog object
compoComponent The component to draw

Component.OnExit(Dialog dlg, Component compo)

Function fired at Dialog.Exit.

Can release open resources by OnInit()

ParameterTypeDefaultDescription
dlgDialog The MyrScript Dialog object
compoComponent The component