Access Keys:
Skip to content (Access Key - 0)
Log in (Access Key - 5)



Toggle Sidebar

Commandupdater

Why?

A command can be enabled or disabled. Attached UI elements will be enabled/disabled automatically by XUL.
The command updater logic is controlling when a command is disabled or enabled.
XUL itself has such a functionality bound to the element commandset. But this is not working as expected.

  • the updater is not responding to all events, i.e. select in tabs
  • passing 'non UI events to the updater is not easy

How it works

Conditions are bound to events on one side and command son the other side. An event is firing a condition. based on the result the
disabled attribute of all commands bound to this event are changed.

How it is realized.

There are two types of events:

  • UI events described by the event name like select, focus, input and the id of the element the event should occur on.
  • Programatically created events
 
<commandupdater id="treecmdupdater">
    <trigger condition="foo()" enablecommands="id1, id2" disablecommands="id3, id4">
        <event name="select" elementid="suitetab"/>
        <event name="docchanged"/>		
    </trigger>
    <trigger enablecommands="id5">
        <event name="focus" elementid="suitetab"/>
    </trigger>
</commandupdater>

The configuration is realized as an XBL element. Conditions are javascript function returning true/false.
The commandupdater has a method raise(eventname). this method has to be called to raise events programmatically.
On startup the commandupdater is registering eventlisteners for each UI event. The eventlistener is a wrapper around the condition.
The wrapper will evaluate the condition and is setting the disabled attributes of the commands bound appropriately.
Triggers are executed in the order they are occuring. So the last will win if commands are registered to the same event not only once.

last edited on Mar 14, 2009 13:30
Adaptavist Theme Builder Powered by Atlassian Confluence