Attaching Event Code


 

The code you attach to a form or control is called an event procedure. Each form and control has a defined set of events that it may recognize. You attach event procedures only for events to which you want a form or control to respond.

 

code.jpg

 

To attach an event procedure to a form:

 

Double-click a blank part of the form to open the form's Code window. You may want to Lock Controls using the Format menu selection or by clicking the Lock toolbar button before double clicking to avoid any accidental movement of the control.

 

Once the double-click is complete, the Code Window will open and the selected object will be displayed in the Objects combobox.

 

 

To attach code to a control:

 

1.   Double-click the control.

2.   In the Event box, select the event to which you want to attach code.

3.   Enter your PL/B code.

4.   Repeat steps 2 and 3 as necessary to attach additional event procedures to the item.

 

Note: When attaching an event procedure, you may also select a form or control from the Object box in the Code window. The information displayed in the Event box then changes to reflect the events for the object you have selected. Text preceded by an asterisk indicates events for which you have written code.

 

Property Window

 

The Properties Window also shows the currently registered events. By clicking the lightning bolt icon in the Property Window toolbar, a list of events for the selected object are shown. Any event for which code exists will show the event procedure label in the Value column.

 

events.jpg

 

Attaching events to objects

 

The Object Name in the code window combobox will indicate an associated routine by showing an asterisk (*) following the object name.

 

The Event combobox in the code window will indicate an associated form routine by showing an asterisk following the event name. If the event is registered to a label outside of the form, the name will be followed by a plus (+) sign.

 



about_designer Assigning Object Properties Using Forms in Programs