EventShortcuts:
Filter:
miSCellaneous_lib/Classes (extension) | Libraries > miSCellaneous > Event and pattern shortcuts

EventShortcuts
ExtensionExtension

holds default and user-defined dictionaries of shortcuts for events and event patterns

Description

Container for dictionaries of shortcuts for the event framework, which can be defined by the user. Shortcuts might be for event keywords or any other (e.g. synth args). At every time one shortcut dictionary is current, but it's only active if EventShortcuts is turned on. Dictionaries are encapsulated and can only be accessed via copies and posting to prevent unintended changes. For event keywords see James Harkins' Practical Guide to Patterns (especially Pattern Guide 07: Value Conversions and Pattern Guide 08: Event Types and Parameters).

NOTE: Implementation of shortcuts works like this: if you don't turn EventShortcuts on at all, nothing is changed in the event framework – if you turn it on a mapping function is prepended to every event type function, if this has not been done before in this session and the event type function hasn't been newly defined since last prepending – if you turn it off the prepended function is still there, but does no mapping.

Therfore shortcuts won't work automatically after new definitions of event types. You'd have to turn EventShortcuts on again or apply the method EventShortcuts: *prefixEventTypes. Quite obviously, switching between different shortcut dictionaries might cause a mess while playing (or pausing and resuming) patterns with these shortcuts. But these are exceptional cases, a typical usage would be defining your personal shortcut dictionary (e.g. in the startup file), turning EventShortcuts on and playing therewith, then maybe turning it off and on again on occasion.

Some pattern classes (e.g. Ppar) don't work correctly with EventShortcuts, but this can be circumvented by applying shortcuts to source event patterns before, see method Pattern: -eventShortcuts. See also PLx_and_live_coding_with_Strings

Class Methods

.add

Adds a new named IdentityDictionary of shortcuts.

Arguments:

name

Symbol or String.

dict

IdentityDictionary of abbreviations (keys given as Symbols) and original names (values given as Symbols).

overwrite

Boolean. Determines if a shortcut dictionary of that name – if existing at all – is overwritten. Defaults to false.

.addOnBase

Adds a new named IdentityDictionary of shortcuts based on the copy of an existing one.

Arguments:

baseName

Symbol or String. Name of the shortcut dictionary to build upon.

newName

Symbol or String. Name of the new shortcut set.

dict

IdentityDictionary of new or/and additional abbreviations (keys given as Symbols) and original names (values given as Symbols).

overwrite

Boolean. Determines if a shortcut dictionary of that name – if existing at all – is overwritten. Defaults to false.

NOTE: overwrite only determines overwriting of an old dictionary of the same name. It doesn't influence the overwriting in the copy of the base dictionary itself, as exactly this is a main aim of the method. (you might want to replace the association 's'-> 'strum' by 's' -> 'server')

.remove

Removes a named IdentityDictionary of that name.

Arguments:

name

Symbol or String.

.removeAll

Removes all IdentityDictionaries except \default.

.copyDict

Returns a copy of a shortcut dictionary of that name (if stored).

Arguments:

name

Symbol or String.

.copyCurrentDict

Returns a copy of the current shortcut dictionary of that name.

Arguments:

name

Symbol or String.

.copyAllDicts

Returns an IdentityDictionary of copies of all stored shortcut dictionaries.

.post

Posts the shortcut dictionary of that name (if stored).

Arguments:

name

Symbol or String.

.postCurrent

Posts the current shortcut dictionary.

.postAll

Posts all shortcut dictionaries.

.makeCurrent

Makes the shortcut dictionary of that name current (if stored).

Arguments:

name

Symbol or String.

.on

Turns on the shortcut mechanism, making it ready for events / patterns to be played. Also invokes EventShortcuts: *prefixEventTypes.

.off

Turns the shortcut mechanism off.

.prefixEventTypes

Puts the remapping function before all event type functions. Therefore a newly defined event type won't work with shortcuts before this has been called ( directly or via EventShortcuts: *on ).

.current

Returns the Symbol of the current shortcut dictionary.

.dictNames

Returns the Symbols of all shortcut dictionaries.

.state

Returns the current state (\on or \off).

Examples