[Solved] Mark a button as clicked on the custom toolbar

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
pjarocki
Posts: 5
Joined: Thu Nov 17, 2022 10:53 am

[Solved] Mark a button as clicked on the custom toolbar

Post by pjarocki »

Is it possible to make buttons on the toolbar behave the same as the standard ones in the application?
I mean that my buttons on the custom toolbar are not staying clicked. I want the same behavior on click as with "Align left". Button stays in clicked state.
I used Protocol handler to handle clicks, but I don't know how to mark a button as clicked.

Using MRI, I found only XAccessibleContext, but there is no option to modify values.
Last edited by pjarocki on Sat Feb 04, 2023 2:50 pm, edited 1 time in total.
LibreOffice 7.4 on Windows 10
User avatar
Zizi64
Volunteer
Posts: 11353
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Mark a button as clicked on the custom toolbar

Post by Zizi64 »

Similar topics (controlling a custom toolbar by custom macros):

viewtopic.php?f=45&t=436
viewtopic.php?p=482726
viewtopic.php?t=65287
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
JeJe
Volunteer
Posts: 2764
Joined: Wed Mar 09, 2016 2:40 pm

Re: Mark a button as clicked on the custom toolbar

Post by JeJe »

with the accessiblecontext of the button this toggles whether its selected

Code: Select all

.setcurrentvalue(.getcurrentvalue xor 1)  
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
JeJe
Volunteer
Posts: 2764
Joined: Wed Mar 09, 2016 2:40 pm

Re: Mark a button as clicked on the custom toolbar

Post by JeJe »

Small example using the find toolbar. The find values button in LibreOffice is set to selected.

Code: Select all


lm = thiscomponent.currentcontroller.frame.layoutmanager
	fb = lm.getelement("private:resource/toolbar/findbar")
	fb.getrealinterface.accessiblecontext.getaccessiblechild(1).setcurrentvalue(1)  

Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
pjarocki
Posts: 5
Joined: Thu Nov 17, 2022 10:53 am

Re: Mark a button as clicked on the custom toolbar

Post by pjarocki »

Zizi64 wrote: Sat Jan 28, 2023 8:27 pm Similar topics (controlling a custom toolbar by custom macros):

viewtopic.php?f=45&t=436
viewtopic.php?p=482726
viewtopic.php?t=65287
Thank you for posting similar topics. I have looked at these topics before I created a new topic. I still was unable to mark the button as selected.


JeJe wrote: Sun Jan 29, 2023 12:41 pm Small example using the find toolbar. The find values button in LibreOffice is set to selected.

Code: Select all


lm = thiscomponent.currentcontroller.frame.layoutmanager
	fb = lm.getelement("private:resource/toolbar/findbar")
	fb.getrealinterface.accessiblecontext.getaccessiblechild(1).setcurrentvalue(1)  

Thank you for posting the example. The code you sent works fine.
I didn't know I can get AccessibleContext from a retrieved item from LayoutManager. This simplifies the code a lot.
LibreOffice 7.4 on Windows 10
Post Reply