classafReflux::GlobalCommand
sys::Obj afReflux::GlobalCommand
@Js
Reusable commands that may be contextually enabled by Views and Panels.
GlobalCommands must be autobuilt by IoC. Contribute GlobalCommand instances to the GlobalCommands service in your AppModule:
@Contribute { serviceType=GlobalCommands# }
static Void contributeGlobalCommands(Configuration config) {
config["myGlobCmd"] = config.autobuild(MyGlobalCommand#)
}
Use the contribution Id to access the command in the GlobalCommands service:
globalCommands.get("myGlobCmd")
globalCommands["myGlobCmd"]
GlobalCommands are disabled by default. To enable, add an enabler function or enable the fwt command directly.
GlobalCommands are automatically added to the EventHub, so to receive events they only need to implement the required event mixin.
Reflux defines the following GlobalCommands:
afReflux.cmdAboutafReflux.cmdCopyafReflux.cmdCutafReflux.cmdExitafReflux.cmdNavBackwardafReflux.cmdNavClearafReflux.cmdNavForwardafReflux.cmdNavHomeafReflux.cmdNavUpafReflux.cmdNewafReflux.cmdPasteafReflux.cmdRedoafReflux.cmdRefreshafReflux.cmdSaveafReflux.cmdSaveAllafReflux.cmdSaveAsafReflux.cmdToggleViewafReflux.cmdUndo
- addEnabler
Void addEnabler(Str listenerId, |->Bool listener, Bool update := true)Adds a function that helps decide if the underlying command should be enabled or not.
If
updateiftruethen the underlying command is updated. Defaults totrue.Sometimes an enabler function gives undesirable results (such as IoC recursion errs) when added from a ctor. If this happens, try setting
updateto false.- addInvoker
Void addInvoker(Str listenerId, |Event? listener)Adds a function to be executed when the command is invoked.
- command
RefluxCommand commandThe wrapped command.
- doInvoke
virtual Void doInvoke(Event? event)Callback for subclasses.
- enabled
Bool enabled { private set }Returns if this command is currently enabled or not. A
GlobalCommandis enabled if any enabler function returns true.- make
new make(Str baseName, |This in)Creates a global command. The base name is used as a localisation key.
- removeEnabler
Void removeEnabler(Str listenerId)Removes the specified enabler function.
- removeInvoker
Void removeInvoker(Str listenerId)Removes the specified invoker function.
- update
virtual Void update()Enables / disables the underlying fwt command based on the
enabledproperty.