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:

See Also:

Since:

API Level 1.0.0

setBackgroundColor(color as Graphics.ColorType) as Void

Set the background color of a Text object.

Parameters:

Since:

API Level 1.3.0

setColor(color as Graphics.ColorType) as Void

Set the color of a Text object.

Parameters:

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:

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 Sep 23, 2024, 3:32:49 PM