macro to activate/deactivate a button on customize toolbar

Creating a macro - Writing a Script - Using the API

macro to activate/deactivate a button on customize toolbar

Postby winhthai » Sat Oct 26, 2013 7:17 am

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

Postby winhthai » Sun Dec 22, 2013 7:16 am

Is there anybody can help? Thanks.
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

Postby hanya » Sun Dec 22, 2013 6:30 pm

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
hanya
Volunteer
 
Posts: 885
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

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

Postby winhthai » Mon Dec 23, 2013 4:22 pm

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
winhthai
 
Posts: 7
Joined: Sat Oct 26, 2013 7:03 am

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

Postby RoryOF » Mon Dec 23, 2013 4:26 pm

Apache OpenOffice 4.1.10 on Xubuntu 20.04.2 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 32527
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

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

Postby winhthai » Mon Dec 23, 2013 4:29 pm

Thanks for your sharing, RoryOF! :)
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

Postby hanya » Mon Dec 23, 2013 5:17 pm

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
hanya
Volunteer
 
Posts: 885
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

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

Postby KamilLanda » Sun Apr 04, 2021 11:50 am

Please has anybody code for Basic (or Python)? Thanks a lot.
LibreOffice 7.1.2.2 Win10
KamilLanda
 
Posts: 4
Joined: Sun Apr 04, 2021 11:46 am

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

Postby JeJe » Mon Apr 05, 2021 11:53 am

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: 1533
Joined: Wed Mar 09, 2016 2:40 pm

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

Postby JeJe » Mon Apr 05, 2021 12:08 pm

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
JeJe
Volunteer
 
Posts: 1533
Joined: Wed Mar 09, 2016 2:40 pm

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

Postby KamilLanda » Mon Apr 05, 2021 12:11 pm

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
KamilLanda
 
Posts: 4
Joined: Sun Apr 04, 2021 11:46 am

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

Postby JeJe » Mon Apr 05, 2021 12:20 pm

Openoffice 4.1.6
Windows 8
JeJe
Volunteer
 
Posts: 1533
Joined: Wed Mar 09, 2016 2:40 pm

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

Postby KamilLanda » Mon Apr 05, 2021 1:38 pm

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
KamilLanda
 
Posts: 4
Joined: Sun Apr 04, 2021 11:46 am

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

Postby JeJe » Mon Apr 05, 2021 1:44 pm

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
JeJe
Volunteer
 
Posts: 1533
Joined: Wed Mar 09, 2016 2:40 pm

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

Postby KamilLanda » Mon Apr 05, 2021 6:02 pm

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
KamilLanda
 
Posts: 4
Joined: Sun Apr 04, 2021 11:46 am

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

Postby RoryOF » Mon Apr 05, 2021 6:13 pm

Some sample code on activating/deactivating a button is at
https://wiki.openoffice.org/wiki/Documentation/DevGuide/Basic/Command_Button

I have not studied how this relates to a User toolbar.
Apache OpenOffice 4.1.10 on Xubuntu 20.04.2 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 32527
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

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

Postby Villeroy » Mon Apr 05, 2021 6:16 pm

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
User avatar
Villeroy
Volunteer
 
Posts: 29701
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany


Return to Macros and UNO API

Who is online

Users browsing this forum: JeJe and 7 guests