|
SWT LPEX v3.0.0 | |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Interface LpexAction can be implemented to define a user action.
The code sample below is used inside a document parser to define the insertAmp editor action (which inserts the string "&" at the cursor), and associate it with the Ctrl+& key in the text area:
lpexView.defineAction("insertAmp", new LpexAction() { public void doAction(LpexView view) { view.doDefaultCommand("insertText &"); } public boolean available(LpexView view) { return !view.queryOn("readonly") && view.currentElement() != 0; } }); if (!lpexView.keyAssigned("c-ampersand.t")) { lpexView.doCommand("set keyAction.c-ampersand.t insertAmp"); } |
The user action may be a new editor action, or it may redefine or extend a default editor action.
An action can be assigned to a key or series of keys with the set keyAction editor command, or to a mouse event with the set mouseAction editor command.
Method Summary | |
---|---|
boolean | available(LpexView lpexView)
This method in the defined action will be called to query the availability of the action. |
void | doAction(LpexView lpexView)
This method in the defined action will be called to run the action. |
Method Detail |
public void doAction(LpexView lpexView)
An action may be run (e.g., from the LPEX command line) with the action editor command, by selecting an associated menu item, or by activating the key or the mouse event to which the action is assigned.
public boolean available(LpexView lpexView)
When this method returns false, menu items associated with this user action will be disabled, the key or mouse event to which this action is assigned will not run it, and neither will the action command.
|
SWT LPEX v3.0.0 | |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |