Java Reference
In-Depth Information
The variable,
url
, holds the URL,
content
holds the displayed text, and
action
is called when the user clicks on the text. The variables
textOrigin
and
textAlignment
are used for the underlying
Text
object defined in
HyperTextSkin
.
The
skin
variable can either be assigned in the
init
block, or using an override
declaration on skin.
protected override var skin = HyperTextSkin {};
The only caution in using the override approach is that the
Control
may not
have been fully initialized when the
Skin
is created, thus certain values may not
be available to the
Skin
when it is first created.
The
HyperTextSkin
object has the bulk of the logic as shown in Listing 5.30.
Listing 5.30
Custom Skin
// used to get default values
package def defaultText = Text{};
public class HyperTextSkin extends Skin {
var hypertext : HyperText = bind control as HyperText;
// Stylesheet settings
public var wrappingWidth: Number =
defaultText.wrappingWidth;
public var underline: Boolean = true;
public var overline: Boolean = defaultText.overline;
public var strikethrough: Boolean =
defaultText.strikethrough;
public var unvisitedFill: Paint = Color.BLUE;
public var visitedFill: Paint = Color.PURPLE;
public var font = Font {};
// local variables
var text: Text;
package var visited: Boolean = false;
...
...
The first item in the
Skin
is to declare a local variable that casts the control to the
specific type. This is just a convenience for later when we have to access vari-
ables from the
HyperText
control. The bind is necessary as the control may not
be set when this local variable is declared.
Second, there is a set of variables that can be set from the style sheet. These must
all be public and remember that a word with a capital letter within the variable
Search WWH ::
Custom Search