Class: Toybox.WatchUi.TextArea

Overview

A representation of a text area that will automatically apply line breaks to fit as much text as possible.

See Also:

Example:

using Toybox.Graphics;
using Toybox.WatchUi;

class MyTextAreaView extends WatchUi.View {

    hidden var myTextArea;

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

    function onShow() {
        myTextArea = new WatchUi.TextArea({
            :text=>"Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
            :color=>Graphics.COLOR_WHITE,
            :font=>[Graphics.FONT_MEDIUM, Graphics.FONT_SMALL, Graphics.FONT_XTINY],
            :locX =>WatchUi.LAYOUT_HALIGN_CENTER,
            :locY=>WatchUi.LAYOUT_VALIGN_CENTER,
            :width=>160,
            :height=>160
        });
    }

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

Since:

API Level 3.1.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 3.1.0

initialize(options as { :text as Lang.String or Lang.ResourceId, :color as Graphics.ColorType, :backgroundColor as Graphics.ColorType, :font as Graphics.FontType or Lang.Array<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(Graphics.ColorType)

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

    • :backgroundColor(Graphics.ColorType)

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

    • :font(Lang.Array, Graphics.FontDefinition)

      A Graphics.FONT_* value representing the desired font face, or an array of such values. Defaults to FONT_MEDIUM

    • :justification(Graphics.TextJustification)

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

See Also:

Since:

API Level 3.1.0

setBackgroundColor(color as Graphics.ColorType) as Void

Set the background color of a Text object.

Parameters:

  • color(Graphics.ColorType)

    A Graphics.COLOR_* value representing the desired background color

Since:

API Level 3.1.0

Throws:

setColor(color as Graphics.ColorType) as Void

Set the color of a Text object.

Parameters:

  • color(Graphics.ColorType)

    A Graphics.COLOR_* value representing the desired text color

Since:

API Level 3.1.0

Throws:

setFont(font as Graphics.FontType or Lang.Array<Graphics.FontType>) as Void

Set the font face of a Text object.

Parameters:

See Also:

Since:

API Level 3.1.0

Throws:

setJustification(justification as Lang.Number) as Void

Set the justification of a Text object.

Parameters:

Since:

API Level 3.1.0

Throws:

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

Set the text string of a Text object.

Parameters:

Since:

API Level 3.1.0

Throws:


Generated Jun 6, 2024 10:31:54 AM