Ask Your Question
1

Set Keyboard shortcuts for extensions

asked 2017-07-22 12:42:16 +0200

d_jan gravatar image

updated 2017-08-07 22:04:48 +0200

I wrote an extension for LibreOffice. I would like to trigger some functions via a keyboard shortcut. However, I was unable to find out how this can be done. I saw that some extension have macros that – by standard – can be assigned to shortcuts, but I did not find out 1) yet how I could trigger functions of my extension via a macro 2) How I can integrate the macros in my extension. (see below – implementation uses uno service, not macros)

Mentioned extension: https://extensions.libreoffice.org/ex... The "update" function should be trigger-able with a keyboard shortcut.

UPDATE:

Turned out that this is a bit more complicated. So the "Accelerators.xcu" part worked (it shows up in the Keyboard-shortcut customization dialog).

However, using the shortcut does not work. I found out that executing a method on the triggering of a shortcut need a UNOService to call.

I created the service and implemented an XJobExecutor Interface. Pressing the assigned Shortcut, Ctrl+Shift+L does not result in execution of the trigger method.

I wonder what goes wrong, but even if I debug the code step by step I can't find out where it goes wrong. I was sadly unable to find a documentation of the .addImplementation method of g_ImplementationHelper which might help me.

edit retag flag offensive close merge delete

Comments

hello @d_jan, this is beyond my expertise, but one thing you could try and see if it helps is changing the updateTrigger into triggerUpdateJob :

g_ImplementationHelper.addImplementation( triggerUpdateJob, "tagtree.qdaaddon.de.fordes.qdatreeappfunctions", ("com.sun.star.task.Job",),)
librebel gravatar imagelibrebel ( 2017-08-08 16:26:58 +0200 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2017-07-23 08:34:00 +0200

librebel gravatar image

Hello @d_jan,

tho i never did this myself, it seems to me that you could just add an "Accelerators.xcu" to your extension, with a node defining a shortcut key to your Update function.

e.g. for CTRL+U:

  <node oor:name="PrimaryKeys">
    <node oor:name="Global">
    ...
    ...
      <node oor:name="U_MOD1" oor:op="replace">
        <prop oor:name="Command">
          <value xml:lang="en-US">vnd.sun.star.script:Library.Module.Update?language=Python&amp;location=application</value>
        </prop>
      </node>
    ...
    ...

The macro URI must be changed to point to your Update function.

Please see Framework / Article / Accelerators Configuration

Hope this helps, lib

edit flag offensive delete link more

Comments

Thanks, lib, I'll give that a try!

d_jan gravatar imaged_jan ( 2017-07-23 17:28:40 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2017-07-22 12:42:16 +0200

Seen: 245 times

Last updated: Aug 07 '17