Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Modality/Classes/MKtl/MKtl.sc
Original file line number Diff line number Diff line change
Expand Up @@ -496,8 +496,12 @@ MKtl { // abstract class
}


resetActions {
elementsDict.do( _.resetAction )
resetActions {|includeGroups = false|
if (includeGroups) {
elementGroup.doRecursive{|e| e.resetAction}
} {
elementsDict.do(_.resetAction)
}
}
resetAction {
"% - please use resetActions.\n".postf(thisMethod);
Expand Down
12 changes: 12 additions & 0 deletions Modality/Classes/MKtl/MKtlElementGroup.sc
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,18 @@ MKtlElementGroup : MKtlElement {

do { |function| elements.do( function ); }

doRecursive {|function, includeGroups = true|
var doOne = { |elemOrGroup, depth|
if (elemOrGroup.isKindOf(MKtlElementGroup)) {
if(includeGroups) { function.value(elemOrGroup, depth) };
elemOrGroup.do({ |item| doOne.value(item, depth + 1) });
} {
function.value(elemOrGroup);
};
};
doOne.value(this, 0);
}

flat {
^this.elements.flat;
}
Expand Down
5 changes: 3 additions & 2 deletions Modality/HelpSource/Classes/MKtl.schelp
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,9 @@ Frees the MKtl again and forgets about its existence.
If there was an device, this closes it.

METHOD:: resetActions
Reset all actions of the elements in this MKtl to nil.
Note that this does not clear group actions.
Reset all actions of the elements in this code::MKtl:: to code::nil::.
argument:: includeGroups
if code::true::, also actions of contained groups are reset.

METHOD:: trace
set the flag whether incoming data are posted or not, default true.
Expand Down
19 changes: 19 additions & 0 deletions Modality/HelpSource/Classes/MKtlElementGroup.schelp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,25 @@ Iterate a function for its enclosed MKtlElements and MKtlGroups
code::
m.elementGroup.do { |el| el.postln };
::

METHOD:: doRecursive
Recursively evaluate a function on itself and its linked MKtlElements and MKtlGroups
argument:: function
the function to evaluate.
Its parameters are
list::
## strong::element:: the element
## strong::depth:: current depth within the traversed tree
::

argument:: includeGroups
if code::true::, function gets evaluated also on code::MKtlElementGroup::s.

code::
m.elementGroup.doRecursive { |el, depth| [el.name, depth].postln };
::


METHOD:: asArray

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