Page 1 of 1

Accelerator for toggle button in toolbar

Posted: Tue May 31, 2022 4:07 am
by jmarch
I'm writing an extension where I want to have an accelerator for a toggle button in a toolbar. I'd like the accelerator to toggle the state of the button just as control-B does for the bold toolbar button.

My toolbar button looks like this:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<oor:component-data xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" oor:name="Addons" oor:package="org.openoffice.Office">
  <node oor:name="AddonUI">
    <node oor:name="OfficeToolBar">
      <node oor:name="com.philolog.hoplitekb.toolbar" oor:op="replace">
        <node oor:name="com.philolog.hoplitekb.button1" oor:op="replace">
          <prop oor:name="URL" oor:type="xs:string">
            <value>com.philolog.hoplitekb:open</value>
          </prop>
          <prop oor:name="ControlType">
					  <value>ToggleButton</value>
				  </prop>
          <prop oor:name="Title" oor:type="xs:string">
            <value xml:lang="en-US">Toggle Hoplite Keyboard</value>
          </prop>
          <prop oor:name="Target" oor:type="xs:string">
            <value>_self</value>
          </prop>
          <prop oor:name="Context" oor:type="xs:string">
            <value>com.sun.star.text.TextDocument</value>
          </prop>
        </node>
      </node>
    </node>...
But I'm not sure what to put in the Accelerators.xcu file to trigger it:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<oor:component-data xmlns:oor="http://openoffice.org/2001/registry"
  xmlns:xs="http://www.w3.org/2001/XMLSchema" oor:name="Accelerators"
  oor:package="org.openoffice.Office">
  <node oor:name="PrimaryKeys">
    <node oor:name="Modules">
      <node oor:name="com.sun.star.text.TextDocument">
        <node oor:name="0_MOD1" oor:op="replace">
          <prop oor:name="Command">
            <value xml:lang="en-US">???????????</value>
          </prop>
        </node>
      </node>
    </node>
  </node>
</oor:component-data>
Thanks in advance for any help on this!

Re: Accelerator for toggle button in toolbar

Posted: Wed Jun 01, 2022 1:45 pm
by JeJe
You want a command that just toggles the state of the button? You may need to write your own macro/code to do that and call it with the url for the macro.

I doubt that Ctrl+B directly changes the state of the button. The state of the bold toolbar button also changes when you move the cursor onto or off bold text.