Section Selection
Functions that apply to selected items, or select items.
Summary
| Return type | Function and summary |
|---|---|
| int | ApplyToAllSelectedDiagrams(Score score, function processFunc, boolean printedStavesOnly) Apply a function to all selected chord diagrams (Diagram objects), individually selected or inside range selection. |
| int | ApplyToAllSelectedDynamics(Score score, function filterFunc, function processFunc, boolean printedStavesOnly) Apply a function to all selected Dynamics, individually selected or inside range selection. |
| int | ApplyToAllSelectedFXProcessors(Score score, function processFunc, boolean printedStavesOnly) Apply a function to all selected FXProcessors, individually selected or inside range selection. |
| int | ApplyToAllSelectedGraphicLines(Score score, function processFunc, boolean printedStavesOnly) Apply a function to all selected graphic lines (Picture objects), individually selected or inside range selection. |
| int | ApplyToAllSelectedImages(Score score, function processFunc, boolean printedStavesOnly) Apply a function to all selected images (Picture objects), individually selected or inside range selection. |
| int | ApplyToAllSelectedStaffTexts(Score score, function processFunc, boolean printedStavesOnly) Apply a function to all selected StaffTexts, individually selected or inside range selection. |
| JumpAndSelectBar(Score score, int barN, Staff staffBegin, Staff stafEnd) Jump to the requested bar number and select it, all staves or the requested staff if not nil. | |
| int | SMApplyToAllSelectedSymbols(Score score, function processFunc, boolean excludeSpecials, boolean printedStavesOnly) Apply a function to all selected symbols, individually selected or continous selection. |
| Symbol | SMFirstSelectedSymbol(Score score, Staff staff, boolean ignoreGhostRest) Returns the first selected symbol (range or individual selection) of the staff or the whole score. |
| Symbol | SMLastSelectedSymbol(Score score, Staff staff, boolean ignoreGhostRest) Returns the last selected symbol (range or individual selection) of the staff or the whole score. |
| int | SelectIndividualSymbols(Score score, boolean printedStavesOnly) From a range selection, select individually all selected symbols. |
Functions
SMApplyToAllSelectedSymbols(Score score, function processFunc, boolean excludeSpecials, boolean printedStavesOnly)
Apply a function to all selected symbols, individually selected or continous selection.
MSLibrary's ApplyToAllSelectedSymbols(...) function doesn't handle individually selected symbols, and browse from last to first, which is safe for symbol deletion. This customized browse selected notes on all staves from first to last, not convenient for deletion. It can skips ghost rests and special symbols, handles individual and continuous (range) selection.
| Parameter | Type | Default | Description |
|---|---|---|---|
| score | Score | score | |
| processFunc | function | Function with two Symbol and Staff arguments, which returns true (= 1) if symbol has been processed, -1 to stop the process. Other returned values are ignored, process continue to next symbol. | |
| excludeSpecials | boolean | false | Exclude ghost rest, mesure repeat (%, %2, %4), and unison in divisi (//)? |
| printedStavesOnly | boolean | false | If true selected symbols on not printed staves are skipped. This has no effect in Scroll mode where all staves are visible. |
- Return
- int: Number of processed symbols
- Error
- if score is not a Score or processFunc is not a function.
- See
- SMApplyToAllSymbols
JumpAndSelectBar(Score score, int barN, Staff staffBegin, Staff stafEnd)
Jump to the requested bar number and select it, all staves or the requested staff if not nil.
Try to position the selected bar near the center of the screen, unlike Score.JumpToBar(...) which also doesn't select.
| Parameter | Type | Default | Description |
|---|---|---|---|
| score | Score | score | |
| barN | int | Bar number, must be lower or equal to Score.NumberOfBars | |
| staffBegin | Staff | nil | If not nil, first or only staff to select, instead of all staves. |
| stafEnd | Staff | nil | If not nil, last staff to select |
- Error
- if
barN > score.NumberOfBarsor staff is notniland not a Staff.
SMFirstSelectedSymbol(Score score, Staff staff, boolean ignoreGhostRest)
Returns the first selected symbol (range or individual selection) of the staff or the whole score.
This function is more accurate than Staff.FirstSelectedSymbol, handles individual selection, and the 3rd argument allows you to ignore ghost rests.
Note: like Staff.FirstSelectedSymbol, the returned symbol may not be included in actions applied to selection (in Edit menu). If the range selection is after the note head but before next note, it is considered as selected by MyrScript, whereas actions in Edit menu won't apply to it.
| Parameter | Type | Default | Description |
|---|---|---|---|
| score | Score | score | |
| staff | Staff | If nil, look for selected symbol on all staves and return the one that begins the first (least symbol.Time) | |
| ignoreGhostRest | boolean | If first selected symbol is a ghost rest, go forward until another kind of symbol is found |
- Return
- Symbol: or
nilif selection contains no symbol
SMLastSelectedSymbol(Score score, Staff staff, boolean ignoreGhostRest)
Returns the last selected symbol (range or individual selection) of the staff or the whole score.
This function is more accurate than Staff.LastSelectedSymbol, handles individual selection, and the 3rd argument allows you to ignore ghost rests.
Note: like Staff.LastSelectedSymbol, the returned symbol may not be included in actions applied to selection (in Edit menu). If the range selection is after the note head but before next note, it is considered as selected by MyrScript, whereas actions in Edit menu won't apply to it.
| Parameter | Type | Default | Description |
|---|---|---|---|
| score | Score | score | |
| staff | Staff | If nil, look for selected symbol on all staves and return the one that ends the last (greatest symbol.Time + symbol.Duration) | |
| ignoreGhostRest | boolean | If last selected symbol is a ghost rest, go backward until another kind of symbol is found |
- Return
- Symbol: or
nilif selection contains no symbol
SelectIndividualSymbols(Score score, boolean printedStavesOnly)
From a range selection, select individually all selected symbols.
In Page mode, if a staff is selected but not printed, the second argument tells if its symbols should be selected individually or not.
| Parameter | Type | Default | Description |
|---|---|---|---|
| score | Score | score | |
| printedStavesOnly | boolean | true | This has no effect in Scroll mode |
- Return
- int: Number of selected symbols, -1 if symbols are already selected individually and no selection is made.
ApplyToAllSelectedDynamics(Score score, function filterFunc, function processFunc, boolean printedStavesOnly)
Apply a function to all selected Dynamics, individually selected or inside range selection.
This browses selected Dynamics on visible (printed) staves from first to last, .
| Parameter | Type | Default | Description |
|---|---|---|---|
| score | Score | score | |
| filterFunc | function | Dynamic are tempo, pedal, ottava or... dynamics. The filter function, if not nil, is here to apply processFunc on the Dynamics you want. This function accepts on Dynamic argument and returns true to be processed. You can use DynamicIsTempo, DynamicIsPedal, DynamicIsVelocity or DynamicIsOttava or create your own filter. nil means no filter, all kind of Dynamics are processed. | |
| processFunc | function | Function with two Dynamic and Staff arguments, which returns true (= 1) if Dynamic has been processed, -1 to stop the process. Other returned values are ignored, process continue to next. | |
| printedStavesOnly | boolean | false | If true selected Dynamics on not printed staves are skipped. This has no effect in Scroll mode where all staves are visible. |
- Return
- int: Number of processed Dynamics
- Error
- if arguments are not valid.
- Example
local nb = ApplyToAllSelectedDynamics(FrontScore(), DynamicIsTempo, function(dyn,staff) print(dyn.TempoValue); return true end, false) print(nb .. " tempo found.")
ApplyToAllSelectedStaffTexts(Score score, function processFunc, boolean printedStavesOnly)
Apply a function to all selected StaffTexts, individually selected or inside range selection.
This browses selected StaffTexts on visible (printed) staves from first to last, excluding rehearsal mark (target) texts.
| Parameter | Type | Default | Description |
|---|---|---|---|
| score | Score | score | |
| processFunc | function | Function with two StaffText and Staff arguments, which returns true (= 1) if text has been processed, -1 to stop the process. Other returned values are ignored, process continue to next. | |
| printedStavesOnly | boolean | false | If true selected texts on not printed staves are skipped. This has no effect in Scroll mode where all staves are visible. |
- Return
- int: Number of processed texts
- Error
- if arguments are not valid.
ApplyToAllSelectedFXProcessors(Score score, function processFunc, boolean printedStavesOnly)
Apply a function to all selected FXProcessors, individually selected or inside range selection.
This browses selected FXProcessors on visible (printed) staves from first to last. Those attached to instruments are not processed.
| Parameter | Type | Default | Description |
|---|---|---|---|
| score | Score | score | |
| processFunc | function | Function with two FXProcessor and Staff arguments, which returns true (= 1) if FX has been processed, -1 to stop the process. Other returned values are ignored, process continue to next. | |
| printedStavesOnly | boolean | false | If true selected FXs on not printed staves are skipped. This has no effect in Scroll mode where all staves are visible. |
- Return
- int: Number of processed FXs
- Error
- if arguments are not valid.
ApplyToAllSelectedGraphicLines(Score score, function processFunc, boolean printedStavesOnly)
Apply a function to all selected graphic lines (Picture objects), individually selected or inside range selection.
This browses selected graphic lines on visible (printed) staves from first to last.
| Parameter | Type | Default | Description |
|---|---|---|---|
| score | Score | score | |
| processFunc | function | Function with two Picture and Staff arguments, which returns true (= 1) if graphic line has been processed, -1 to stop the process. Other returned values are ignored, process continue to next. | |
| printedStavesOnly | boolean | false | If true selected lines on not printed staves are skipped. This has no effect in Scroll mode where all staves are visible. |
- Return
- int: Number of processed graphic lines
- Error
- if arguments are not valid.
ApplyToAllSelectedImages(Score score, function processFunc, boolean printedStavesOnly)
Apply a function to all selected images (Picture objects), individually selected or inside range selection.
This browses selected images on visible (printed) staves from first to last.
| Parameter | Type | Default | Description |
|---|---|---|---|
| score | Score | score | |
| processFunc | function | Function with two Picture and Staff arguments, which returns true (= 1) if image has been processed, -1 to stop the process. Other returned values are ignored, process continue to next. | |
| printedStavesOnly | boolean | false | If true selected images on not printed staves are skipped. This has no effect in Scroll mode where all staves are visible. |
- Return
- int: Number of processed images
- Error
- if arguments are not valid.
ApplyToAllSelectedDiagrams(Score score, function processFunc, boolean printedStavesOnly)
Apply a function to all selected chord diagrams (Diagram objects), individually selected or inside range selection.
This browses selected chord diagrams on visible (printed) staves from first to last.
| Parameter | Type | Default | Description |
|---|---|---|---|
| score | Score | score | |
| processFunc | function | Function with two Diagram and Staff arguments, which returns true (= 1) if digram has been processed, -1 to stop the process. Other returned values are ignored, process continue to next. | |
| printedStavesOnly | boolean | false | If true selected images on not printed staves are skipped. This has no effect in Scroll mode where all staves are visible. |
- Return
- int: Number of processed diagrams
- Error
- if arguments are not valid.