RAD Studio |  |

Associating an Event with an Existing Event Handler
See Also
Collapse All

You can reuse code by writing event handlers that respond to more than one event. For example, many applications provide speed buttons that are equivalent to drop-down menu commands. When a button initiates the same action as a menu command, you can write a single event handler and assign it to both the button's and the menu item's OnClick event.

To associate an event with an existing event handler

1. On the form, select the component whose event you want to handle.
2. On the Events page of the Object Inspector, select the event to which you want to attach a handler.
3. Click the down arrow in the Value column next to the event to open a list of previously written event handlers. (The list includes only event handlers written for events of the same name on the same form.) Select from the list by clicking an event-handler name.

The previous procedure is an easy way to reuse event handlers. Action lists and in the VCL, action bands, however, provide powerful tools for centrally organizing the code that responds to user commands. Action lists can be used in cross-platform applications, whereas action bands cannot.
See Also

Working with Events and Event Handlers

Using the Sender Parameter

Displaying and Coding Shared Events

Associating Menu Events with Event Handlers

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