macro to activate/deactivate a button on customize toolbar

Creating a macro - Writing a Script - Using the API
Post Reply
winhthai
Posts: 7
Joined: Sat Oct 26, 2013 7:03 am

macro to activate/deactivate a button on customize toolbar

Post by winhthai »

I am looking for a Basic macro code to activate/deactivate a button (with assign macro) in customize toolbar.
Like "Form Controls" toolbar, when turning "Design Mode On/Off" button, some other buttons are activated while default is deactivated.
I appreciate it very much if somebody can help! Thank you.
Last edited by acknak on Sat Oct 26, 2013 2:02 pm, edited 1 time in total.
Reason: add "macro" to subject
OpenOffice.org 3.4.1 on MacOS 10.5
winhthai
Posts: 7
Joined: Sat Oct 26, 2013 7:03 am

Re: macro to activate/deactivate a button on customize toolb

Post by winhthai »

Is there anybody can help? Thanks.
OpenOffice.org 3.4.1 on MacOS 10.5
hanya
Volunteer
Posts: 885
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

Re: macro to activate/deactivate a button on customize toolb

Post by hanya »

So you want to create toggle button. You have to implement css.frame.XDispatch interface to update the status of your toolbar button.
Once you implement it for your dispatch command, you can use some functions for complex toolbars. This means you need own UNO component implementation.

To change the state of your toggle button on some toolbar, set boolean value for State element of css.frame.FeatureStateEvent that passed to css.frame.XStatusListener::statusChanged method of control set through css.frame.XDispatch::addStatusListener method of your dispatcher.
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
winhthai
Posts: 7
Joined: Sat Oct 26, 2013 7:03 am

Re: macro to activate/deactivate a button on customize toolb

Post by winhthai »

Thanks for your sharing, Hanya!
Based on your guidance, I will try to look for css.frame.FeatureStateEvent code.
If possible, could you share some sample code so that I can implement it quickly?
Thank you so much.
OpenOffice.org 3.4.1 on MacOS 10.5
User avatar
RoryOF
Moderator
Posts: 33646
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: macro to activate/deactivate a button on customize toolb

Post by RoryOF »

Apache OpenOffice 4.1.13 on Xubuntu 22.04.1 LTS and very infrequently on Win2K/XP
winhthai
Posts: 7
Joined: Sat Oct 26, 2013 7:03 am

Re: macro to activate/deactivate a button on customize toolb

Post by winhthai »

Thanks for your sharing, RoryOF! :)
OpenOffice.org 3.4.1 on MacOS 10.5
hanya
Volunteer
Posts: 885
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

Re: macro to activate/deactivate a button on customize toolb

Post by hanya »

There is an example for complex toolbar in SDK/examples/cpp/complextoolbarcontrols, and the document:
https://wiki.openoffice.org/wiki/Framew ... r_controls
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
KamilLanda
Posts: 4
Joined: Sun Apr 04, 2021 11:46 am

Re: macro to activate/deactivate a button on customize toolb

Post by KamilLanda »

Please has anybody code for Basic (or Python)? Thanks a lot.
LibreOffice 7.1.2.2 Win10
JeJe
Volunteer
Posts: 2054
Joined: Wed Mar 09, 2016 2:40 pm

Re: macro to activate/deactivate a button on customize toolb

Post by JeJe »

What exactly are you asking KamilLanda that isn't answered by the links in this ancient thread already?
Openoffice 4.1.6
Windows 8
JeJe
Volunteer
Posts: 2054
Joined: Wed Mar 09, 2016 2:40 pm

Re: macro to activate/deactivate a button on customize toolb

Post by JeJe »

There was an example/sample where someone put a dialog in a toolbar by setting the toolbar as its parent - so you can have whatever buttons you want and the same control over them that you have in any other dialog.

I can't find it unfortunately - maybe someone else can/remembers it...
Openoffice 4.1.6
Windows 8
KamilLanda
Posts: 4
Joined: Sun Apr 04, 2021 11:46 am

Re: macro to activate/deactivate a button on customize toolb

Post by KamilLanda »

winhthai wrote:I am looking for a Basic macro code to activate/deactivate a button (with assign macro) in customize toolbar.
I also looking for a Basic code.
But the link from RoryOF comment doesn't exists, and the link from Hanya is for C++.
LibreOffice 7.1.2.2 Win10
JeJe
Volunteer
Posts: 2054
Joined: Wed Mar 09, 2016 2:40 pm

Re: macro to activate/deactivate a button on customize toolb

Post by JeJe »

Openoffice 4.1.6
Windows 8
KamilLanda
Posts: 4
Joined: Sun Apr 04, 2021 11:46 am

Re: macro to activate/deactivate a button on customize toolb

Post by KamilLanda »

But it is depended on BeanShell :-(. Maybe it is not possible to create necessary Listeners in Basic, I don't know.
LibreOffice 7.1.2.2 Win10
JeJe
Volunteer
Posts: 2054
Joined: Wed Mar 09, 2016 2:40 pm

Re: macro to activate/deactivate a button on customize toolb

Post by JeJe »

We're back to what you want to do? Do you want a toggle button? You can easily create a toolbar button to run a macro that changes the label on the toolbar button from "off" to "on" or something similar.

Edit:
It could be a label that is a unicode tick ballot box switching to an empty ballot box - something like that.
Openoffice 4.1.6
Windows 8
KamilLanda
Posts: 4
Joined: Sun Apr 04, 2021 11:46 am

Re: macro to activate/deactivate a button on customize toolb

Post by KamilLanda »

Originally I hoped somebody has a code for complextoolbar (like in Hanya link for C++), but purely in Basic. But nevermind.
LibreOffice 7.1.2.2 Win10
User avatar
RoryOF
Moderator
Posts: 33646
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: macro to activate/deactivate a button on customize toolb

Post by RoryOF »

Some sample code on activating/deactivating a button is at
https://wiki.openoffice.org/wiki/Docume ... and_Button

I have not studied how this relates to a User toolbar.
Apache OpenOffice 4.1.13 on Xubuntu 22.04.1 LTS and very infrequently on Win2K/XP
User avatar
Villeroy
Volunteer
Posts: 30793
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: macro to activate/deactivate a button on customize toolb

Post by Villeroy »

RoryOF wrote:I have not studied how this relates to a User toolbar.
Not at all. This refers to a button on a user-defined dialog or a form control button attached to a document.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Post Reply