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
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.