CommandEvent

This event type is fired when the program is about to carry out a "command" - a specific program function. The user can initiate commands by selecting items from menus, pressing buttons mapped to commands, or by mouse selections (e.g., selecting from a right-click context menu). See Commands for a list of the command functions.

The event target for this event type is the mainWindow object.

The CommandEvent class has only one subtype:

As with most event types, a CommandEvent fires before the system carries out its normal handling for the command. This allows you to block a command entirely by calling preventDefault() on the event object in your handler. For example, if you wanted to prevent the user from being able to exit out of PinballY using the menus, you could do something like this:

mainWindow.on("command", ev => { if (ev.id == command.Quit) ev.preventDefault(); });

Properties