« Return to Thread: Manipulating menus at runtime

Re: Manipulating menus at runtime

by Juergen Schmidt-3 :: Rate this Message:

Reply to Author | View in Thread

Hi Laurent,

a status listener is your friend. Ideally you have your own frame and
listener manager to handle different frames appropriately.

see for exmaple

public void addStatusListener(com.sun.star.frame.XStatusListener
xControl, com.sun.star.util.URL aURL) {

     if (aURL.Protocol.compareTo("org.openoffice.demo:") == 0) {
         if (aURL.Path.compareTo("MyCommand") == 0) {
             FeatureStateEvent aEvent = new FeatureStateEvent();
             aEvent.FeatureURL = aURL;
             aEvent.Source = (XDispatch) this;
             aEvent.IsEnabled = (m_myconditionorwhtaever.length() > 0 ?
true : false);
             aEvent.Requery = false;

             xControl.statusChanged(aEvent);
         }
     }
     // store the listener related to the frame for later use ...
     FrameManager.addListener(m_xFrame, xControl, aURL.Path);
}

The addStatusdListener method is per default empty in the generated NB
project, if you use our NB plugin ;-)

Play a little bit around with this stuff and if you have further
questions feel free to come back.


Laurent Godard wrote:

> Hi all
>
> I wrote an extension and now wants to enable/disable menu entries
> dynamically at runtime both for my extension and legacy menu entries
>
> Is there a way and could someone point me in the right direction
> Any codesnippet in any language or some keywords and basic steps are
> welcommed
>
> Thanks in advance
>
> Laurent
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@...
> For additional commands, e-mail: dev-help@...
>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...

 « Return to Thread: Manipulating menus at runtime

LightInTheBox - Buy quality products at wholesale price!