Writing Event Handlers

From Delphi for PHP Documentation Wiki

Jump to: navigation, search

Summary: Describes how to write an event handler for a project.

Your source code usually responds to events that might occur to a component at runtime, such as a user clicking a button or choosing a menu command. The code that responds to an occurrence is called an event handler. The event handler code can modify property values and call methods.

To write an event handler

  • Click the component on your form for which you want to write an event handler.
  • Double-click the component on the form to create the default event for the component. The "Code Editor" appears with the cursor inside the event.
  • Type the body of the event code at the location of the cursor.
  • Switch back to the Design tab to add another event to the component.
  • Select that component again, then click the "Events" tab in the" Object Inspector".
  • Locate the event in the event list in the " Object Inspector" and double-click the name of the event. A new skeleton event is created and the "Code Editor" appears again with the cursor inside the new event.
  • Type the code that will execute when the event occurs at runtime.
  • Continue adding event handlers to the components on your form using this method.
Personal tools