Plugins and Keyboard Shortcuts

Having trouble installing Oxygen? Got a bug to report? Post it all here.
bpopp
Posts: 37
Joined: Tue Nov 30, 2010 7:34 pm

Plugins and Keyboard Shortcuts

Post by bpopp »

I think there might be a slight discrepancy in the documentation regarding plugins. Normally this wouldn't bother me too much, but I can't seem to get either method to work.

The Documentation and sample plugins use this convention:
<extension type="selectionProcessor"
class="ro.sync.sample.plugin.caplines.CapLinesPluginExtension" keyboardShortcut="ctrl shift EQUALS"/>
Futher down the documentation says:
To compose string representations of the desired shortcut keys you can go to the Oxygen Menu Shortcut Keys preferences page, press Edit on any action, press the desired key sequence and use the representation which appears in the edit dialog.
In Oxygen 12.2, this looks like:

Code: Select all

Ctrl+Shift+Equals
I've tried using both conventions with the standard "LowerCase" plugin, and neither seems to work. I know the plugin is being loaded because I tried to delete the plugin folder while Oxygen was running and it would error when trying to delete the JAR file.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Plugins and Keyboard Shortcuts

Post by sorin_ristache »

Hello,
bpopp wrote:I've tried using both conventions with the standard "LowerCase" plugin, and neither seems to work.
A shortcut set as in this example:

Code: Select all

keyboardShortcut="ctrl shift EQUALS"
should work. Please send us the plugin.xml file of your Oxygen plugin.

You are right, the shortcut as it is displayed in the dialog box from the Menu Shortcut Keys panel does not work because it contains the '+' sign. A shortcut set in plugin.xml must contain a space instead of the '+' sign. Also you have to use only lowercase for the modifier keys, that is only ctrl and shift (not Ctrl, not CTRL, not Shift, not SHIFT). This is the behavior in the current version (12.2) but we will relax these restrictions in a future version and we will correct the user manual accordingly so that the '+' sign is replaced automatically by Oxygen with a space character and also uppercase modifiers like Ctrl or CTRL are converted automatically to lowercase.


Regards,
Sorin
bpopp
Posts: 37
Joined: Tue Nov 30, 2010 7:34 pm

Re: Plugins and Keyboard Shortcuts

Post by bpopp »

My plugin.xml looks like:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plugin SYSTEM "../plugin.dtd">
<plugin
name="LowerCase"
description="Convert the selection to lowercase"
version="1.0.0"
vendor="SyncRO"
class="ro.sync.sample.plugin.lowercase.LowercasePlugin"
classLoaderType="preferReferencedResources">
<runtime>
<library name="lib/lowercase.jar"/>
</runtime>
<extension type="selectionProcessor"
class="ro.sync.sample.plugin.lowercase.LowercasePluginExtension" keyboardShortcut="ctrl shift MINUS"/>
</plugin>
This is the unedited LowerCase plugin provided by you guys and it resides in a lib folder below the plugin.xml file. My plugins preference panel looks like (to show it's installed):

Image

I'm selecting the text I want to make lowercase, and then pressing CTRL+SHIFT+"-" (neither "-" key seems to work).
adrian
Posts: 2850
Joined: Tue May 17, 2005 4:01 pm

Re: Plugins and Keyboard Shortcuts

Post by adrian »

Hi,

Can you please check if the shortcut is correctly shown for the plugin in the contextual(popup) menu from Text mode(popup menu -> Plugins -> LowerCase)?

Note that Oxygen displays the shortcut as Ctrl+Shift+Minus. e.g.
Image
Does the action work correctly when invoked from this popup menu?


Do you by any chance use a custom keyboard layout?

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
sanGeoff
Posts: 42
Joined: Mon Aug 18, 2014 11:50 pm

Re: Plugins and Keyboard Shortcuts

Post by sanGeoff »

Do keyboard shortcuts still work for plugins like this? I cant seem to get it to work whatever I do.
adrian
Posts: 2850
Joined: Tue May 17, 2005 4:01 pm

Re: Plugins and Keyboard Shortcuts

Post by adrian »

Hi,

Yes, they work just the same, if they have a keyboard shortcut assigned within plugin.xml (extension/@keyboardShortcut) as seen in the example above.
Note that by default most sample plugins don't have such a shortcut set.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
sanGeoff
Posts: 42
Joined: Mon Aug 18, 2014 11:50 pm

Re: Plugins and Keyboard Shortcuts

Post by sanGeoff »

adrian wrote:Hi,

Yes, they work just the same, if they have a keyboard shortcut assigned within plugin.xml (extension/@keyboardShortcut) as seen in the example above.
Note that by default most sample plugins don't have such a shortcut set.

Regards,
Adrian
Hum, well I cant seem to get it to work. All I should need is the plugin.xml extension code and a class right?

plugin.xml:

Code: Select all

<extension type="generalExtension" class="oxyMod.shortcutTest" keyboardShortcut="ctrl alt UP"/>
shortcutTest:

Code: Select all

package oxyMod;
import ro.sync.exml.plugin.general.GeneralPluginContext;
import ro.sync.exml.plugin.general.GeneralPluginExtension;
public class shotchutTest implements GeneralPluginExtension {
@Override
public void process(GeneralPluginContext context) {
System.out.println("Test"); // And, I have a breakpoint
}
}
I tried pressing ctrl+alt+UP after <oXygen/> opened and in a document, nothing happens and process() doesn't trigger.
I know i am working in the right files since, if I change the class attribute to something else, it gives an error.
Also, would the keyboard shortcut show up in the <oXygen/> options if we have an @actionName attribute?

I was wondering if it might have changed since. I noticed a shortcut method in PluginExtensionDescription but don't know how what that class is used for.

<oXygen/> XML Author 17.1, build 2015102718 (Standalone)

Thanks.
adrian
Posts: 2850
Joined: Tue May 17, 2005 4:01 pm

Re: Plugins and Keyboard Shortcuts

Post by adrian »

Hi,
Also, would the keyboard shortcut show up in the <oXygen/> options if we have an @actionName attribute?
No. Plugins are treated separately.
Check the Plugins contextual menu (see the image with the menu from one of my previous posts). If it's in working order, you should see the shortcut key there.

Note that plugins of these types (selectionProcessor, documentProcessor, generalExtension) only work in Text mode. For Author mode you can either implement a WorkspaceAccessPlugin, or better yet, work with frameworks (document type specific) and Author actions that can either make use of builtin or custom Author operations (they implement ro.sync.ecss.extensions.api.AuthorOperation).

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Radu
Posts: 9018
Joined: Fri Jul 09, 2004 5:18 pm

Re: Plugins and Keyboard Shortcuts

Post by Radu »

Hi,

Just to update this thread, in Oxygen 18.0 a workspace access plugin extension can register a new action with a default shortcut to Oxygen using the new API:

Code: Select all


ro.sync.exml.workspace.api.standalone.StandalonePluginWorkspace.getActionsProvider().registerAction(String actionID, Object action, String defaultKeyStroke);
after this users can also change the action key stroke from the Oxygen Preferences->Menu Shortcut Keys page.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply