MFunc:
Filter:
Classes (extension) | Modality

MFunc : AbstractFunction : Object
ExtensionExtension

MFunc is a proxy for multiple, modal functions.
Source: MFunc.sc
Subclasses: MFdef

Description

MFunc is a proxy for multiple, modal functions which can replace a single function with easily configurable flexible behavior.

It contains a dictionary of named functions (i.e. a behavior repertoire), an ordered list of the function names, lists of combinations of functions, and lists of the currently active functions and names.

The MFunc's behavior can be reconfigured at any time:

MFunc is intended for use in modal interfaces, so for example, when a single slider has an MFunc as its action, it can have functions that

This is intended to replace complicated cascades of if-statements (which easily accumulate when coding modal user interface functions). Instead of setting flags for modes and reading them in control structure logic, one can use MFuncs to switch between modes by a. enabling the functions desired in the new mode, b. disabling the ones that should be off in the new mode, and c. keeping all other functions independent by leaving them untouched.

Class Methods

MFunc.new(pairs, modes, initMode, modeLists)

make a new MFunc, like this:

Inherited class methods

Instance Methods

.activeNames

the names of the currently active funcs

.mode

.mode = name

get name of the currently active mode, set currently active mode by name.

.modes

the available modes

.modeLists

the modeLists

.funcDict

the repertoire of all functions

.orderedNames

the ordered names of all available functions

.activeFuncs

the currently active functions

.value( ... args)

calls .value on the activeFuncs, returns a list of the return values.

.enable(names)

.disable(names)

enable and disable functions by name(s)

.add(name, func, active: true, addAction: 'replace', otherName)

add or replace a function by name, optionally relative to another name.

Arguments:

name

name by which to store func

func

the func to store

active

flag whether the func should become active

addAction

optional addAction, default is \addLast

otherName

addActions \addBefore, \addAfter need a name relative to which to add.

.remove(name)

fully remove functions by name or names

.addFirst(name, func, active: true)

.addLast(name, func, active: true)

.replace(name, func, active: true)

short methods indicating where to add or replace

.addBefore(name, func, active: true, otherName)

.addAfter(name, func, active: true, otherName)

short methods for adding relative to another name

Arguments:

name

the name for the new func

func

the new func to add

active

flag whether active

otherName

the name relative to which to add

.useTry

.useTry = value

get and set flag whether to use .tryValue istead of .value

.tryValue( ... args)

wrap all function evaluations in try { }, so that if one fails, it posts good info, and all later functions in the list will still be evaluated.

Inherited instance methods

Undocumented instance methods

.at(key)

.doOnServerTree(server)

.makeExclusiveModes(name, modeList, modeNames)

.tryValueAt(keys ... args)

.valueAt(keys ... args)

Examples