Each type of widget includes a set of functions, in addition
to those described in “Rich UI widget fields.”
The following functions are available for widgets of type
RUIWidget:
- The function fadeIn causes the widget
to fade in (to be presented slowly), and the function fadeOut causes
the widget to fade out (to be slowly made invisible):
fadeIn (duration int in, callback EffectCallback)
fadeOut (duration int in, callback EffectCallback)
Each
function takes two parameters:
- duration
- Number of milliseconds between the start and end of the process,
whether the widget is fading in or fading out
- callback
- A reference to a function that is invoked as soon as the widget
fades in or out. That function takes no parameters and has no return
value. If you do not wish to specify a function, set this argument
to null.
Here is an example:
myButton.fadeOut(1000, null);
- The function focus causes the widget
to receive focus:
focus()
For example, a button in focus is highlighted, and
the user's pressing the ENTER key is equivalent to the user's clicking
the button. Similarly, a text field in focus (if not read only) includes
a cursor so that the user enters data by typing a printable character
without first tabbing to the field.
The user can press TAB repeatedly
to cycle through the available fields. With each keypress, the focus
moves either to the next application field or to a field on the browser;
for example, to the web address field.
Here is an example invocation
of
focus:
myButton.focus();
- The function morph lets you change the
display of a widget over time. The function repeatedly calls one of
your functions; in this way, your code specifies the behavior caused
by the runtime invocation:
morph (duration int in, callback EffectCallback, morphFunction MorphFunction )
The function takes three parameters:
- duration
- Number of milliseconds between the start and end of the process.
- callback
- A reference to a function that is invoked as soon as the process
is complete. That function takes no parameters and has no return value.
If you do not wish to specify a function, set this second argument
to null.
- customMorphFunction
- A reference to a custom morph function, which is a function
invoked repeatedly during the duration mentioned earlier. . The custom
morph function takes two parameters: the widget being changed and
a float assigned by the EGL runtime. The float is a fraction between
0 and 1 and reflects the progress made toward the end of the duration.
(At each invocation of the custom morph function, the value of that
float is larger.) That fraction is based on a calculation of how many
times the custom morph function is invoked, given the duration available
and the amount of time required to run the custom logic. The custom
morph function has no return value.
Here is an example:
myButton.morph(1000, null, myCustomMorphFunction);
- The function resize lets you change
the size of a widget over time:
resize (width int in, height int in,
duration int, callback EffectCallback)
The function takes four parameters:
- width
- The desired final width, in pixels.
- height
- The desired final height, in pixels.
- duration
- Number of milliseconds between the start and end of the process.
- callback
- A reference to a function that is invoked as soon as the process
is complete. That function takes no parameters and has no return value.
If you do not wish to specify a function, set this argument to null.
Here is an example:
myButton.resize(100, 100, 1000, myFunction);