controlNamePrefix

controlNamePrefix(): String;

The controlNamePrefix method of the Window class is a prototype method that you can reimplement in your own schemas if you want to prefix your own control names. You can define a prefix for any Control subclass (for example, a prefix of lbx_ for a ListBox control) so that when you add a control to a form in Painter, Jade inserts the appropriate prefix when prompting you for the name of the control.

To prefix a control, you must first define (reimplement) a controlNamePrefix method for the appropriate control subclass.

The following example shows the reimplementation of this method defined for the Button class in a user-defined schema.

controlNamePrefix(): String;
vars
begin
    return "btn_";
end;

The controlNamePrefix method is used only by the Jade Painter. No check for a control name prefix is made when you use the Class Browser or logic to add controls.

If you do not define a valid controlNamePrefix method for a control class, the Jade Painter uses the default control naming rules, which may be overridden.

If the control class has a caption property, the initial value for the caption is the control name (with a capitalized first letter and without the control name prefix applied) if you accept the default name when prompted to do so, or the actual text (with a capitalized first letter) that you specified as part of the name. For example, if the Painter detects you have changed the control name (for example, from btn_Button1 to btn_OK), the caption property is made equal to the name with the prefix removed so that the caption displays only the value that you specified (in this example, OK).

The name property for the control displays the full name (btn_OK in this example) in the Properties dialog.

The controlNamePrefix method can be defined once only for any class in a schema branch. You therefore cannot override a prefix if the control is in a superschema and it has already implemented the controlNamePrefix method. In this case, set the superschema to the current schema and then change the method.

Control prefixes are not applied when you create a form using the Form Wizard, which prefixes all controls with ctl_. (The type of control is not known until the form is built after you have specified the name of the control.)