ViEventManager Class Reference
| Inherits from | NSObject |
| Declared in | ViEventManager.h |
Overview
The event manager is used to automatically run code when specific
events occur. An event handler is defined as a Nu function, typically
an anonymous function created with the Nu do operator. An event
handler will receive zero or more arguments, depending on the event.
Any return value is ignored.
The standard events are described below.
Constants
Standard event names
Document Controller events
didFinishLaunching-
Emitted when Vico has finished launching.
arguments: none
willResignActive-
Emitted when Vico resigns active state (ie, loses focus).
arguments: none
didBecomeActive-
Emitted when Vico becomes active (ie, regains focus).
arguments: none
didAddDocument-
Emitted when a new document is opened.
arguments: document
didRemoveDocument-
Emitted when a document is closed.
arguments: document
Document events
willChangeURL-
Emitted before a document changes it's URL.
arguments: document, url
didChangeURL-
Emitted after a document changed it's URL.
arguments: document, url
willLoadDocument-
Emitted before a document is loaded.
arguments: document, url
didLoadDocument-
Emitted after a document was loaded.
arguments: document
willSaveDocument-
Emitted before a document is being saved.
arguments: document
didSaveDocument-
Emitted after a document was saved.
arguments: document
willSaveAsDocument-
Emitted before a document is being saved at a new URL.
arguments: document, url
didSaveAsDocument-
Emitted after a document was saved at a new URL.
arguments: document, url
willCloseDocument-
Emitted before a document is closed.
arguments: document
didCloseDocument-
Emitted after a document was closed.
arguments: document
didModifyDocument-
Emitted after a document was modified.
arguments: document, range, delta
didMakeView-
Emitted after a new document view was created.
arguments: document, view, text
willChangeSyntax-
Emitted before a document changes language syntax.
arguments: document, language
didChangeSyntax-
Emitted after a document changed language syntax.
arguments: document, language
Text events
caretDidMove-
Emitted after the caret has changed in a text view.
arguments: text
Window events
willSelectDocument-
Emitted before the selected document is changed in a window.
arguments: window, document
didSelectDocument-
Emitted after the selected document was changed in a window.
arguments: window, document
willSelectView-
Emitted before the selected view is changed in a window.
arguments: window, view
didSelectView-
Emitted after the selected view was changed in a window.
arguments: window, view
willSelectTab-
Emitted before the selected tab is changed in a window.
arguments: window, tab controller
didSelectTab-
Emitted after the selected tab was changed in a window.
arguments: window, tab controller
Tab Controller events
didAddView-
Emitted after a view was added to a tab.
arguments: view
didCloseView-
Emitted after a view was removed from a tab.
arguments: view
Tasks
Other Methods
-
+ defaultManagerThe default global event manager.
Emitting events
-
– emit:for:withArguments:Emit an event immediately.
-
– emitDelayed:for:withArguments:Emit an event in the next run loop iteration.
Registering event handlers
-
– on:by:do:Register a handler for an event by a specific object.
-
– on:do:Register an event handler.
Removing event handlers
-
– clear:for:Remove all events handlers for a specific object.
-
– clear:Remove all handlers for an event.
-
– clearFor:Remove all handlers for an object.
-
– clearRemove all handlers for all events.
-
– remove:Remove an event handler.
Instance Methods
clear:
Remove all handlers for an event.
- (void)clear:(NSString *)eventParameters
- event
The name of the event; cannot be
nil.
Declared In
ViEventManager.hclear:for:
Remove all events handlers for a specific object.
- (void)clear:(NSString *)event for:(id)ownerParameters
- event
The name of the event; cannot be
nil.
- owner
The object that is responsible for emitting the event.
Declared In
ViEventManager.hclearFor:
Remove all handlers for an object.
- (void)clearFor:(id)ownerParameters
- owner
The object that is responsible for emitting the event.
Declared In
ViEventManager.hemit:for:withArguments:
Emit an event immediately.
- (void)emit:(NSString *)event for:(id)owner withArguments:(id)argumentsParameters
- event
The name of the event; cannot be
nil.
- owner
The object that is responsible for emitting the event.
- arguments
The arguments to the event handler. Can either be an NSArray or a Nu list.
Discussion
You should not manually emit any of the standard events.
Declared In
ViEventManager.hemitDelayed:for:withArguments:
Emit an event in the next run loop iteration.
- (void)emitDelayed:(NSString *)event for:(id)owner withArguments:(id)argumentsParameters
- event
The name of the event; cannot be
nil.
- owner
The object that is responsible for emitting the event.
- arguments
The arguments to the event handler. Can either be an NSArray or a Nu list.
Discussion
You should not manually emit any of the standard events.
Declared In
ViEventManager.hon:by:do:
Register a handler for an event by a specific object.
- (NSInteger)on:(NSString *)event by:(id)owner do:(NuBlock *)expressionParameters
- event
The name of the event; cannot be
nil.
- owner
The object that emitted the event.
- expression
A Nu anonymous function (
doblock). See the Nu documentation. The number of arguments to the function must match the number of arguments emitted.
Return Value
A unique event ID.
Discussion
This event handler is called whenever the event is emitted by the
owner object.
See Also
Declared In
ViEventManager.hon:do:
Register an event handler.
- (NSInteger)on:(NSString *)event do:(NuBlock *)expressionParameters
- event
The name of the event; cannot be
nil.
- expression
A Nu anonymous function (
doblock). See the Nu documentation. The number of arguments to the function must match the number of arguments emitted.
Return Value
A unique event ID.
Discussion
This event handler is called whenever the event is emitted,
regardless of the emitting object.
See Also
Declared In
ViEventManager.hremove:
Remove an event handler.
- (void)remove:(NSInteger)eventIdParameters
- eventId
An event ID as returned by on:by:do:.
Declared In
ViEventManager.h