Class: Toybox.WatchUi.Text

Overview

A representation of a text resource.

See Also:

Example:

using Toybox.Graphics;
using Toybox.WatchUi;

class MyTextView extends WatchUi.View {

    hidden var myText;

    function initialize() {
        View.initialize();
    }

    function onShow() {
        myText = new WatchUi.Text({
            :text=>"Hello World!",
            :color=>Graphics.COLOR_WHITE,
            :font=>Graphics.FONT_LARGE,
            :locX =>WatchUi.LAYOUT_HALIGN_CENTER,
            :locY=>WatchUi.LAYOUT_VALIGN_CENTER
        });
    }

    function onUpdate(dc) {
        dc.setColor(Graphics.COLOR_WHITE, Graphics.COLOR_BLACK);
        dc.clear();
        myText.draw(dc);
    }
}

Since:

API Level 1.0.0

Instance Method Summary collapse

Instance Method Details

draw(dc as Graphics.Dc) as Void

Draw Text to the device context (Dc).

Parameters:

Since:

API Level 1.0.0

initialize(options as { :text as Lang.String or Lang.ResourceId, :color as Graphics.ColorType, :backgroundColor as Graphics.ColorType, :font as Graphics.FontType, :justification as Graphics.TextJustification or Lang.Number, :identifier as Lang.Object, :locX as Lang.Numeric, :locY as Lang.Numeric, :width as Lang.Numeric, :height as Lang.Numeric, :visible as Lang.Boolean })

Constructor

Parameters:

  • options(Lang.Dictionary)

    A Dictionary containing the options for the Text object

    • :text(Lang.String, Lang.ResourceId)

      The text string or ResourceId of a string resource

    • :color(Lang.Number)

      A Graphics.COLOR_* value representing the desired text color, defaults to COLOR_WHITE

    • :backgroundColor(Lang.Number)

      A Graphics.COLOR_* value representing the desired background color, defaults to COLOR_TRANSPARENT

    • :font(Graphics.FontType)

      A value representing the desired font face, defaults to FONT_MEDIUM

    • :justification(Lang.Number)

      A Graphics.TEXT_JUSTIFY_* value representing the desired justification, defaults to TEXT_JUSTIFY_LEFT

See Also:

Since:

API Level 1.0.0

setBackgroundColor(color as Graphics.ColorType) as Void

Set the background color of a Text object.

Parameters:

  • color(Lang.Number)

    A Graphics.COLOR_* value representing the desired background color

Since:

API Level 1.3.0

setColor(color as Graphics.ColorType) as Void

Set the color of a Text object.

Parameters:

  • color(Lang.Number)

    A Graphics.COLOR_* value representing the desired text color

Since:

API Level 1.0.0

setFont(font as Graphics.FontType) as Void

Set the font face of a Text object.

Parameters:

See Also:

Since:

API Level 1.0.0

setJustification(justification as Graphics.TextJustification or Lang.Number) as Void

Set the justification of a Text object.

Parameters:

  • justification(Lang.Number)

    A Graphics.TEXT_JUSTIFY_* value representing the desired justification

Since:

API Level 1.0.0

setText(text as Lang.String or Lang.ResourceId) as Void

Set the text string of a Text object.

Parameters:

Since:

API Level 1.0.0


Generated Apr 17, 2024 9:40:39 AM