Inherit User defined Events Methods and Properties

Visual LANSA

Inherit User-defined Events, Methods and Properties

In this section three sample forms are used:

Form A - Ancestor Component

FormA defines a protected event OKPressed and a private (hidden) method GetInfo:

Begin_Com Protect(OKPressed) Private(GetInfo) Role(*EXTENDS #PRIM_FORM)

 

Form B - Inheriting Component

FormB inherits from FormA and makes the OKPressed event public:

Begin_Com Public(OKPressed) Role(*EXTENDS #FORMA)

 

Form C - Owner Component

FormC owns FormB and contains an event routine to handle the OKPressed event:

Define_Com Class(#FORMB) Name(#FORMB)

 

evtroutine  handling(#FORMB.OKPressed)

endroutine

 

 

When you create user-defined events, properties and methods for a form, by default they will be visible to other forms that will use this form as an ancestor.

For example a form (#FRMDETAIL) has a user-defined property Employee:

Define_pty name(Employee) set(*auto #empno) get(*auto #empno) help('Use the Employee property to pass the employee number')

 

a custom-defined event OKPressed:

define_evt name(OKPressed)

 

and a custom-defined method GetInfo:

mthroutine name(GetInfo)

   fetch fields(#detflds) from_file(pslmst) with_key(#empno)

endroutine 

 

The OKPressed event is visible in the Events tab of the Details tab. The Employee property is visible in the Features tab:

And the GetInfo method is visible in the Methods tab of the Details tab.

If you now specify this form (FRMDETAIL) as the ancestor of another form, the code used to define the user-defined event, method and property is not visible, but the event, property and method are visible through the Details tab or the help and you can use them in the code of the inheriting form just as you would in the ancestor form.

Ý 6.21.4 Advanced Inheritance Topics