Nyári István wrote:
I created a project with a OfficeMenuBar and OfficeToolBar. They contain
same submenus, with same URL.
In the main java class I definied an addStatusListener function what
change the state of menu by FeatureStateEvent.
public void addStatusListener(com.sun.star.frame.XStatusListener xControl,
com.sun.star.util.URL aURL) {
if (aURL.Protocol.compareTo("com.thotsoft:") == 0) {
if (aURL.Path.compareTo("Start") == 0) {
FeatureStateEvent aEvent = new FeatureStateEvent();
aEvent.FeatureURL = aURL;
aEvent.Source = (XDispatch) this;
aEvent.IsEnabled = !isStarted;
aEvent.Requery = false;
xControl.statusChanged(aEvent);
}
}
}
This statusListener works fine on the OfficeMenuBar elements, but it has
no effects on the OfficeToolBar elements. What is the solution, if i have
to change the toolbar elements' state too?
Shortly: how can I enable and disable ToolBar elements from Java code in
running time?
I use ImageButton in toolbar, what is a simple ToggleButton by
specification what can be controlled by status change.
<node oor:name="OfficeToolBar">
<node oor:name="com.thotsoft" oor:op="replace">
<node oor:name="m2" oor:op="replace">
<prop oor:name="URL" oor:type="xs:string">
<value>com.thotsoft:Start</value>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value>_self</value>
</prop>
<prop oor:name="Title" oor:type="xs:string">
<value/>
<value xml:lang="en">Start</value>
</prop>
<prop oor:name="ControlType" oor:type="xs:string">
<value>ImageButton</value>
</prop>
</node>
</node>
</node>
Hi Nyári,
first of all you also have to send statusChanged notifications at any
time the state has been changed. Most complex toolbar controls react on
notifications send out by statusChanged. You use the ImageButton control
which definitely supports it. You can have a look at the OpenOffice.org
SDK which includes an example for complex toolbar controls written in C++.
The menu implementation is a little bit different as it adds/removes
itself as listener whenever someone opens the menu. Please keep in mind
that this is an implementation detail and can be changed in the future.
The toolbar controls just call addStatusListener once and
removeStatusListener at the end of their lifetime! This could be an
explanation for the described behavior.
Regards,
Carsten
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]