Page 1 of 1

macro to activate/deactivate a button on customize toolbar

PostPosted: Sat Oct 26, 2013 7:17 am
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.

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

PostPosted: Sun Dec 22, 2013 7:16 am
by winhthai
Is there anybody can help? Thanks.

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

PostPosted: Sun Dec 22, 2013 6:30 pm
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.

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

PostPosted: Mon Dec 23, 2013 4:22 pm
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.

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

PostPosted: Mon Dec 23, 2013 4:26 pm
by RoryOF

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

PostPosted: Mon Dec 23, 2013 4:29 pm
by winhthai
Thanks for your sharing, RoryOF! :)

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

PostPosted: Mon Dec 23, 2013 5:17 pm
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

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

PostPosted: Sun Apr 04, 2021 11:50 am
by KamilLanda
Please has anybody code for Basic (or Python)? Thanks a lot.

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

PostPosted: Mon Apr 05, 2021 11:53 am
by JeJe
What exactly are you asking KamilLanda that isn't answered by the links in this ancient thread already?

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

PostPosted: Mon Apr 05, 2021 12:08 pm
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...

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

PostPosted: Mon Apr 05, 2021 12:11 pm
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++.

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

PostPosted: Mon Apr 05, 2021 12:20 pm
by JeJe

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

PostPosted: Mon Apr 05, 2021 1:38 pm
by KamilLanda
But it is depended on BeanShell :-(. Maybe it is not possible to create necessary Listeners in Basic, I don't know.

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

PostPosted: Mon Apr 05, 2021 1:44 pm
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.

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

PostPosted: Mon Apr 05, 2021 6:02 pm
by KamilLanda
Originally I hoped somebody has a code for complextoolbar (like in Hanya link for C++), but purely in Basic. But nevermind.

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

PostPosted: Mon Apr 05, 2021 6:13 pm
by RoryOF
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.

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

PostPosted: Mon Apr 05, 2021 6:16 pm
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.