Enabled State

There are numerous cases where a component will be required to not accept any user input and not allow any state changes. These cases include:

  • The component is outside the modal context. This occurs when a modal component is being displayed (such as a modal dialog window) that is not an ancestor of the component.
  • The application as a whole is not accepting user input.
  • An ancestor of the component is not enabled.
  • The component itself has been programmatically disabled.
  • The application could be busy. For example, in the case of a server-side application, it might be synchronizing the state of the user interface with the server.

User input can be rejected by adding a call to Echo.Client.verifyInput() to each event listener, and returning immediately if the result is false. The following code snippet shows a hypothetical click listener that uses verifyInput():

    _processClick: function(e) {
        if (!this.client.verifyInput(this.component)) {
            return true;
        }
        [ code to actually process click would follow here ]
    }

Note that in this case, where the events are fired from the CoreJS Core.Web.Event processor, true is returned to indicate that the event may bubble to other listeners.

If the event's default action would alter the state of the user interface in and of itself, the case where verifyInput() evaluates to false should first invoke Core.Web.DOM.preventEventDefault(e); to prevent the default behavior from occurring. Likewise, if the state could have changed anyway, code should be added to undo any such state change, e.g., by re-rendering a portion of the component (prevention is obviously far more desirable).