UpPreviousNext

Exposing Resources

When designing a class with reuse in mind, you must decide what aspects of the class will be customizable on a per instance basis. Within Builder Xcessory, you can do this by exposing resources .

A resource on a component object is exposed when its default value can be overridden for a particular instance of the class. Ordinarily, you expose resources when you wish to vary a resource value for different instances of a class. For example, you might want to allow users of the LabelField class described at the beginning of this chapter to set the value of the labelString resource for each instance of the class.


Note: For any resource that you want to expose within a class, you must specify a default resource value in the class definition.

Exposing a resource

To expose a resource, follow these steps:

1. Switch the Browser to Classes view.

2. Update the Resource Editor for the desired component object.

3. Scroll the Resource Editor to the desired resource.

4. Set the resource to the value that you wish each instance to take by default.

5. Select Expose from the option menu to the right of the resource text field.


Note: Exposed resources are designated on the Resource Editor with an "open eye" icon to the left of the option menu. The option menu continues to display the resource placement setting (for example, "Code" or "App").

Editing the value of an exposed resource

To edit the value of an exposed resource on a class instance, follow these steps:

1. Select a class instance (Be sure to be in Browser:Instance view).

2. Update the Resource Editor.

The Resource Editor now displays exposed resources with the notation:
<element_name>.<resource>

3. Scroll the Resource Editor to the desired resource.

4. Edit and apply the resource value as you would any other resource value.

Only the currently selected instance takes this resource value. The default resource value in the class definition is unchanged.


Hint: To temporarily turn off display of the element's instance name in an exposed resource name (that is, display background instead of myElementInstance.background ), hold MB1 down while the cursor is over the name. To locate a particular resource quickly, use the Resource Editor Search Area.
UpPreviousNext