diff --git a/Modality/Classes/MKtl/MKtl.sc b/Modality/Classes/MKtl/MKtl.sc index 564d907d..9169bab4 100644 --- a/Modality/Classes/MKtl/MKtl.sc +++ b/Modality/Classes/MKtl/MKtl.sc @@ -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); diff --git a/Modality/Classes/MKtl/MKtlElementGroup.sc b/Modality/Classes/MKtl/MKtlElementGroup.sc index 7a08c396..1b8afe57 100644 --- a/Modality/Classes/MKtl/MKtlElementGroup.sc +++ b/Modality/Classes/MKtl/MKtlElementGroup.sc @@ -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; } diff --git a/Modality/HelpSource/Classes/MKtl.schelp b/Modality/HelpSource/Classes/MKtl.schelp index 142ff98d..b201f8bc 100644 --- a/Modality/HelpSource/Classes/MKtl.schelp +++ b/Modality/HelpSource/Classes/MKtl.schelp @@ -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. diff --git a/Modality/HelpSource/Classes/MKtlElementGroup.schelp b/Modality/HelpSource/Classes/MKtlElementGroup.schelp index c153d87c..6f20978d 100644 --- a/Modality/HelpSource/Classes/MKtlElementGroup.schelp +++ b/Modality/HelpSource/Classes/MKtlElementGroup.schelp @@ -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::