MKtlElementGroup:
Filter:
Modality-toolkit/Classes (extension) | Libraries > Modality

MKtlElementGroup
ExtensionExtension

A group of MKtlElements or MKtlElementGroups

Description

MKtlElementGroup is used in the hierarchical tree structure of MKtl: elements. It can do an action when any of the elements it contains is touched. MKtlElementGroup can also be used to make custom groups of MKtlElements and other MKtlElementGroups. The elements are stored in a fixed order, and can be accessed equally via either an index (a number) or a key (a symbol). See also Creating_Named_Groups and Creating_Custom_Elements_and_Groups

Class Methods

.new

create a new MKtlElementGroup with a name, a source MKtl, and a list of elements

.newFrom

create an MKtlElementGroup from a list of elements

.fromDesc

create an MKtlElementGroup from an element description, as contained in a desc file.

Instance Methods

.elements

gets and sets the Array of elements contained

.dict

gets and sets the Event containing all elements of the group

.elAt

get an element inside the group via a list of indices or keys.

.action

a Function that is fired when any of the enclosed elements is touched. The first argument of this function is the MKtlElement that is touched. The arguments that follow are it's enclosing MKtlElementGroups up until this.

.do

Iterate a function for its enclosed MKtlElements and MKtlGroups

.doRecursive

Recursively evaluate a function on itself and its linked MKtlElements and MKtlGroups

Arguments:

function

the function to evaluate. Its parameters are

  • element the element
  • depth current depth within the traversed tree
includeGroups

if true, function gets evaluated also on MKtlElementGroups.

.asArray

Returns:

a nested Array structure of the enclosed elements. Any enclosed element that is an MKtlElementGroup will be converted into a normal Array

.flat

Returns:

a flat Array of all enclosed MKtlElements.

.gui

open a GUI window for this

Arguments:

parent

the parent window (will create one if not specified)

bounds

the desired bounds of the window

Returns:

an MKtlElementGroupGUI

.value

get and set the value of all elements in the group (nested if group is nested)

.deviceValue

get and set the deviceValue of all elements in the group

.prevValue

.prevDeviceValue

get the previous value or deviceValue of all elements in the group

.valueAction

.deviceValueAction

set the value or deviceValue of all elements in the group, and do the action of the group only (i.e. not of each element contained)

.isOn

for groups of MIDI [\noteOn, \noteOff], return true if the \on element was activated last. see How_to_create_a_description_file_for_MIDI

Examples