Laxkit
0.0.7.1
|
A kind of event filter windows can use to help process keyboard shortcuts. More...
Public Member Functions | |
ShortcutHandler (const char *areaname=NULL, ShortcutDefs *cuts=NULL, WindowActions *wactions=NULL) | |
virtual ShortcutHandler * | duplicate () |
Return a new ShortcutHandler object. The action and shortcut lists are refcounted, not duplicated. | |
virtual int | NumActions () |
virtual WindowAction * | Action (int i) |
Return the WindowAction object at index i. | |
virtual WindowActions * | Actions () |
virtual WindowAction * | FindAction (unsigned int key, unsigned int state, int mode) |
Return the WindowAction object corresponding to a matching key, state, and mode if mode>=0. | |
virtual int | FindActionNumber (unsigned int key, unsigned int state, int mode) |
Return action number listed in shortcuts stack. Does not read from actions stack. | |
virtual int | FindActionNumber (const char *actionname, int len=-1) |
From the actions stack, return the action number corresponding to actionname. | |
virtual int | NumShortcuts () |
virtual ShortcutDef * | Shortcut (int i) |
Return the ShortcutDef object at index i. | |
virtual ShortcutDefs * | Shortcuts () |
virtual int | FindShortcutIndex (unsigned int key, unsigned int state, int mode) |
Return the index of a shortcut (in shortcuts stack) matching key, state, and mode if mode>=0. | |
virtual int | FindShortcutFromAction (int action, int startingfrom) |
virtual int | InstallShortcuts (ShortcutDefs *cuts) |
virtual int | AddMode (int mode, const char *modestr, const char *name, const char *desc) |
virtual int | AddShortcut (unsigned int key, unsigned int state, unsigned int mode, unsigned int action) |
Add a shortcut. Assumes action is in actions, does not check. Return index of shortcut. | |
virtual unsigned int | AddAction (unsigned int action, const char *nname, const char *desc, const char *icon, unsigned int mode, int assign) |
Add a window action. | |
virtual unsigned int | Add (unsigned int action, unsigned int key, unsigned int state, unsigned int mode, const char *nname, const char *desc, const char *icon, int assign) |
Add an action with a default shortcut. | |
virtual int | RemoveAction (int action) |
Remove action from actions stack, and remove any shortcuts bound to that action number. | |
virtual int | ClearShortcut (unsigned int key, unsigned int state, int mode) |
virtual int | ClearShortcut (int i) |
virtual int | UpdateKey (unsigned int key, unsigned int state, unsigned int mode, unsigned int newaction) |
Update which action is triggered by the specified key. | |
virtual int | ReassignKey (unsigned int newkey, unsigned int newstate, unsigned int oldkey, unsigned int oldstate, unsigned int mode, unsigned int action) |
Public Member Functions inherited from Laxkit::anObject | |
anObject () | |
Set object_id=getUniqueNumber(). | |
virtual | ~anObject () |
Empty virtual destructor. | |
virtual const char * | whattype () |
Returns the type of anObject. | |
virtual anObject * | duplicate (anObject *ref=NULL) |
virtual int | inc_count () |
Increment the data's count by 1. Returns count. | |
virtual int | dec_count () |
Decrement the count of the data, deleting if count is less than or equal to 0. | |
virtual int | the_count () |
Public Attributes | |
char * | area |
Public Attributes inherited from Laxkit::anObject | |
int | suppress_debug |
DeleteRefCountedFunc | deleteMe |
Called when the count is decremented to 0. | |
unsigned long | object_id |
char * | object_idstr |
Protected Attributes | |
ShortcutDefs * | shortcuts |
WindowActions * | actions |
int | index |
int | keyindex |
int | deviceid |
Protected Attributes inherited from Laxkit::anObject | |
int | _count |
The reference count of the object. |
A kind of event filter windows can use to help process keyboard shortcuts.
Windows and interfaces would have one ShortcutHandler object, that points to action and shortcut stacks elsewhere. ShortcutHandler objects can keep info related to tracking shortcut chain input.
This class stores lists of actions and shortcut definitions, and can return an action based on sequences of key presses.
|
virtual |
Add a shortcut. Assumes action is in actions, does not check. Return index of shortcut.
If shortcut key+state+mode existed already, then assign the action to that one.
References Laxkit::PtrStack< T >::e, FindShortcutIndex(), Laxkit::PtrStack< T >::n, and Laxkit::PtrStack< T >::push().
Referenced by Add(), Laxkit::ShortcutManager::dump_in_atts(), ReassignKey(), and UpdateKey().
Return 0 for success, nonzero for error.
References Laxkit::PtrStack< T >::n, and Laxkit::PtrStack< T >::remove().
|
virtual |
Return action number listed in shortcuts stack. Does not read from actions stack.
If mode>0, then the key must have that mode. Return -1 for not found, else the action number.
References Laxkit::PtrStack< T >::e, and FindShortcutIndex().
Referenced by LaxInterfaces::ViewerWindow::CharInput(), LaxInterfaces::ViewportWindow::CharInput(), LaxInterfaces::PatchInterface::CharInput(), and Laxkit::ShortcutManager::dump_in_atts().
From the actions stack, return the action number corresponding to actionname.
-1 is returned if not found.
If len<0 then use strlen(actionname). Otherwise, use len number of characters of actionname.
References Laxkit::PtrStack< T >::e, and Laxkit::PtrStack< T >::n.
|
virtual |
When you overwrite a key in a ShortcutWindow, you need to syncronize which keys are mapped to which actions. This will try to preserve the order of the shortcuts.
Return -1 for old equals new, so nothing done.
References AddShortcut(), Laxkit::PtrStack< T >::e, FindShortcutIndex(), and Laxkit::PtrStack< T >::remove().
|
virtual |
Update which action is triggered by the specified key.
If key didn't exist, then install new shortcut.
Return 0 for sucess, or nonzero for error.
References AddShortcut(), Laxkit::PtrStack< T >::e, and FindShortcutIndex().
Referenced by Laxkit::ShortcutManager::UpdateKey().