20002009 Ericsson AB. All Rights Reserved. The contents of this file are subject to the Erlang Public License, Version 1.1, (the "License"); you may not use this file except in compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/. Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. Default Values gs_chapter6.xml
The Default Value Model

When a new object is created, a set of options is provided by the application. Options which are not explicitly given are taken care of by the parent (the container object).

In the example shown above, the window provides default values for options like location and background color. If an application cannot use the default values provided by GS, new ones can be configured. For example, the following code creates a red button at location y=30.

The syntax for the default option is , where is the name of any GS object. The special keywords or which denote button, radio button, and check button can be used.

The semantics for the default option can be expressed as follows: If an object of kind is created and no value for is given, then use as the value. Only options of syntax can be given a default values. Default values may be inherited in several steps. In the following example, the button will show the text "Cancel".

Default values are inherited so that changed default values only affect new objects, not existing objects.

Default values only have meaning when creating child objects, since objects which cannot have children cannot have default options. An example is buttons.

The following example illustrates how default options can be used:

Example of Default Options