OverlayText

Create text over other apps. Call show() to display it and to apply later changes. Enable press, drag or hold tracking with track(). Read current values with state(); text() and background() are methods.

Syntax

OverlayText(text="", position=(0, 0), color="#FFFFFFFF", size=16, background=None)

Constructor parameters

NameDescription
textString
Initial text content.
Optional · Positional or named
Default: ""
positionPoint | tuple[Number, Number]
Initial position as Point or tuple/list (x, y). Point carries scale/anchor metadata.
Optional · Positional or named
Default: (0, 0)
colorColor | String | Number
Initial text color.
Optional · Positional or named
Default: white
sizeNumber
Initial text size (sp).
Optional · Positional or named
Default: 16
backgroundColor | String | Number | None
Initial background color. None means transparent/no background.
Optional · Positional or named
Default: None

Returns

Example

badge = OverlayText("Running...", Point(320, 160, scale="width", anchor="top"), background=None)
badge.color("#FF00E676").background("#66000000").size(18).track(press=True, move=True, hold=True, hold_ms=700)
badge.show()

state = badge.state()
if state["status"] == 2:
    MacroPanel.notify("Badge is moving")

p = badge.get_point()
r = badge.get_region()
if r is not None:
    r.highlight("yellow", auto_hide_ms=600)

badge.hide()   # hide fast
badge.show()   # show again quickly
badge.off()    # fully release

Fields

NameDescription
xNumber
Top-left X position in pixels. Writable before show().
Default: 0
yNumber
Top-left Y position in pixels. Writable before show().
Default: 0
scaleString
Coordinate scale copied from Point positions.
Default: fixed
anchorString
Coordinate anchor copied from Point positions.
Default: none
argbColor
Text color. Assign with Color/string/number values. Use overlay.color(value) for method chaining.
Default: white
size_spNumber
Text size in sp. Use overlay.size(sp) for method chaining.
Default: 16
Constructor example
badge = OverlayText("Ready", Point(420, 220, scale="width", anchor="top"), background=None)
badge.show()

Methods

13 methods

OverlayText.off_all

Turn off and release every overlay text created by the current flow, without affecting parallel flows.

Syntax

OverlayText.off_all()

Returns

None — No return value.

Example

# Release overlays owned by this flow
a = OverlayText("Running", (24, 120))
a.show()
OverlayText.off_all()

OverlayText.text

Set text content. Call show() to update the text on screen.

Syntax

overlay.text(value)

Parameters

NameDescription
valueString
Text content.
Required · Positional or named
No default

Returns

OverlayText — Returns this overlay so you can call another method on it.

Example

# Configure or inspect a flow-owned overlay
badge = OverlayText("Ready", (24, 120))
badge.show()
badge.text("Running")
badge.show()

OverlayText.color

Update text color.

Syntax

overlay.color(value)

Parameters

NameDescription
valueColor | String | Number
Color value.
Required · Positional or named
No default

Returns

OverlayText — Returns this overlay so you can call another method on it.

Example

# Configure or inspect a flow-owned overlay
badge = OverlayText("Ready", (24, 120))
badge.color("#FF00E676")
badge.show()

OverlayText.background

Update background color. Passing None removes the background.

Syntax

overlay.background(value=None)

Parameters

NameDescription
valueColor | String | Number | None
Background color, or None for transparent/no background.
Optional · Positional or named
Default: None

Returns

OverlayText — Returns this overlay so you can call another method on it.

Example

# Configure or inspect a flow-owned overlay
badge = OverlayText("Ready", (24, 120))
badge.background("#66000000")
badge.show()
badge.background(None)
badge.show()

OverlayText.size

Update text size (sp).

Syntax

overlay.size(sp)

Parameters

NameDescription
spNumber
Text size in sp.
Required · Positional or named
No default

Returns

OverlayText — Returns this overlay so you can call another method on it.

Example

# Configure or inspect a flow-owned overlay
badge = OverlayText("Ready", (24, 120))
badge.size(20)
badge.show()

OverlayText.position

Update draw position with a Point or tuple/list (x, y). Point carries scale/anchor metadata.

Syntax

overlay.position(position)

Parameters

NameDescription
positionPoint | tuple[Number, Number]
New position.
Required · Positional or named
No default

Returns

OverlayText — Returns this overlay so you can call another method on it.

Example

# Configure or inspect a flow-owned overlay
badge = OverlayText("Ready", (24, 120))
badge.position((80, 160))
badge.show()

OverlayText.track

Configure press, drag and hold tracking. If all flags are False, the text stays fixed and touches pass through it. Where a movable highlight overlaps the text, enabled text interaction receives touches first. A gesture that starts outside the text stays with the highlight.

Syntax

overlay.track(press=False, move=False, hold=False, hold_ms=600)

Parameters

NameDescription
pressBoolean
Report PRESSED after a short press is released without dragging or holding.
Optional · Positional or named
Default: False
moveBoolean
Allow dragging the text. Movement within the device touch threshold does not move it; dragging starts after the threshold is exceeded.
Optional · Positional or named
Default: False
holdBoolean
Report HOLDING after hold_ms, then HOLDED when released; dragging takes priority.
Optional · Positional or named
Default: False
hold_msNumber
Time to hold before HOLDING, in milliseconds. Values below 150 use 150.
Optional · Positional or named
Default: 600

Returns

OverlayText — Returns this overlay so you can call another method on it.

Example

# Configure or inspect a flow-owned overlay
badge = OverlayText("Ready", (24, 120))
badge.track(press=True, move=True, hold=True, hold_ms=700)
badge.show()
print(badge.state())

OverlayText.get_point

Get current top-left point of this overlay text. This position is updated after drag moves. This does not consume interaction events.

Syntax

overlay.get_point()

Returns

Point — Current overlay position in screen pixels.

Example

# Configure or inspect a flow-owned overlay
badge = OverlayText("Ready", (24, 120))
badge.show()
point = badge.get_point()
print(point.x, point.y)

OverlayText.get_region

Get a region that wraps current overlay text bounds. Returns None when the overlay is not visible or not measured yet. This does not consume interaction events.

Syntax

overlay.get_region()

Returns

Region? — Bounding region for overlay text, or None. Always check for None before using the region.

Example

# Configure or inspect a flow-owned overlay
badge = OverlayText("Ready", (24, 120))
badge.show()
bounds = badge.get_region()
if bounds is not None:
    print(bounds.width, bounds.height)

OverlayText.show

Show the text, including after hide(), and apply changes to its content, style, position, tracking or writable fields. Call show() again after each configuration change. If only the position changes while visible, only the latest position is kept for the next display frame. The call returns before it appears: returned x/y are the accepted position, and overlay_width_px/overlay_height_px are None. Other updates wait until applied. While visible, show() preserves interaction state and events if tracking is unchanged. Showing after hide() or changing tracking resets to IDLE; changing tracking also cancels the previous gesture.

Syntax

overlay.show()

Returns

dict — Current overlay state dictionary.

Example

# Configure or inspect a flow-owned overlay
badge = OverlayText("Ready", (24, 120))
badge.show()
badge.text("Running")
print(badge.show())

OverlayText.hide

Hide the text. Call show() to display it again.

Syntax

overlay.hide()

Returns

dict — Current overlay state dictionary.

Example

# Configure or inspect a flow-owned overlay
badge = OverlayText("Ready", (24, 120))
badge.show()
badge.hide()
badge.show()

OverlayText.off

Turn off overlay text and release resources.

Syntax

overlay.off()

Returns

dict — Current overlay state dictionary.

Example

# Configure or inspect a flow-owned overlay
badge = OverlayText("Ready", (24, 120))
badge.show()
print(badge.off())

OverlayText.state

Read the latest state. With the corresponding tracking enabled: Press and release → PRESSED (1). Drag → MOVING (2); release → MOVED (4). Hold for hold_ms → HOLDING (3); release → HOLDED (7). Other states: IDLE (0), HIDDEN (5), OFF (6). Pressing down alone creates no event; dragging takes priority over holding. PRESSED, MOVED and HOLDED are returned once, then reset to IDLE. MOVING and HOLDING remain while active. Only the latest state is kept; a new event replaces an unread one. Cancellation creates no completion event. Pending position changes are applied before reading. Only state() consumes terminal events. They do not expire, but polling every 100 ms cannot retain every event between reads.

Syntax

overlay.state()

Returns

dict — State dictionary with status/status_label, tracking flags, and optional overlay width/height in pixels.

Example

# Configure or inspect a flow-owned overlay
badge = OverlayText("Ready", (24, 120))
badge.track(press=True, move=True)
badge.show()
state = badge.state()
print(state["status_label"])