RAD Studio |  |

Responding to System Events

When the widget layer receives an event notification from the operating system, it generates a special event object (QEvent or one of its descendants) to represent the event. The event object contains read-only information about the event that occurred. The type of the event object indicates the type of event that occurred.

The widget layer notifies your CLX component of system events using a special signal of type event. It passes the QEvent object to the signal handler for the event. The processing of the event signal is a bit more complicated than processing other signals because it goes first to the application object. This means an application has two opportunities to respond to a system event: once at the application level (TApplication) and once at the level of the individual component (your TWidgetControl or THandleComponent descendant.) All of these classes (TApplication, TWidgetControl, and THandleComponent) already assign a signal handler for the event signal from the widget layer. That is, all system events are automatically directed to the EventFilter method, which plays a role similar to the WndProc method on VCL controls.

EventFilter handles most of the commonly used system notifications, translating them into the events that are introduced by your component's base classes. Thus, for example, the EventFilter method of TWidgetControl responds to mouse events (QMouseEvent) by generating the OnMouseDown, OnMouseMove, and OnMouseUp events, to keyboard events (QKeyEvent) by generating the OnKeyDown, OnKeyPress, OnKeyString, and OnKeyUp events, and so on.

The following topics describe how to customize the way your control works with system events:

- Commonly used events
- Overriding the EventFilter method
- Generating Qt events

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!