Step Determining whether the object is allowed to process events

The next step of the event handling process checks to see if the responsible widget (the wx.EvtHandler) is currently allowed to process events.

A window can be set to allow or disallow event processing by calling the wx.EvtHandler method SetEvtHandlerEnabled(boolean). The effect of disallowing event processing is that the widget is completely bypassed in the event process, binding objects associated with the object are not searched for, and the processing in this step goes down the no branch.

Enabling or disabling a widget at the event handler level is not the same as disabling the widget at the UI level. Disabling a widget at the UI level is done using the wx.Window method Disable() and Enable(). Disabling a widget in the UI sense means that the user cannot interact with the disabled widget. Usually, the disabled widget is grayed out on the screen to indicate its status. A window that has been disabled at the UI level won't be able to generate any events; however, if it's on the container hierarchy for other events, it still processes events it receives. For the remainder of this section, we'll use enabled and disabled in the wx.EvtHandler sense, referring to whether the widget is allowed to process events.

The check for the enabled/disabled state of the initiating object happens in the ProcessEvent() method which is called by the wxPython system to start and handle the event dispatch mechanism. We'll see the ProcessEvent() method again and again during this process—it's the method in the wx.EvtHandler class that actually implements much of the event process depicted in figure 3.3. The ProcessEvent() method returns True if event processing is complete at the end of the method. Processing is considered complete if a handler function is found for the instance and event combination being processed. The handler function can explicitly request further processing by calling the wx.Event method Skip(). In addition, if the initiating object is a subclass of wx.Window, it can filter the event

Yes

Figure 3.5

Tests whether the triggering object is enabled

Figure 3.5

Tests whether the triggering object is enabled

using a special object called a validator. Validators will be discussed in more detail in chapter 9.

Was this article helpful?

0 0

Post a comment