Skip to content

macOS: textSetColor is a no-op on a Text label (padding cell bakes attributedStringValue, overriding setTextColor:) #10856

Description

@steinybot

Summary

On macOS, textSetColor has no visible effect on a Text() label. The label always renders in the default labelColor (white in dark appearance), regardless of the color passed.

Cause

Text() creates an NSTextField.labelWithString (crates/perry-ui-macos/src/widgets/text.rs), then install_label_cell (crates/perry-ui-macos/src/widgets/padding.rs:208) captures and re-sets the field's attributedStringValue (line 219). An NSTextField with an attributedStringValue ignores setTextColor: — the attributed string's baked-in color attribute (the default labelColor) wins. So perry_ui_text_set_colorsetTextColor: is silently overridden.

Reproduce

  • macOS, Perry 0.5.1622 (local build), Darwin 25.6.0 arm64.
  • const t = Text("hi"); textSetFontSize(t, 40); textSetColor(t, 1, 0, 0, 1) on a white background.
  • The label renders in the default color (white in dark appearance / invisible on white), not red. A pure-red, -green, -blue label all render white on a dark background — the color argument is ignored entirely.

Expected

textSetColor colors the label.

Workaround

Re-set the string after coloring (textSetString(widget, text)), which replaces the stale attributedStringValue with a plain stringValue, so textColor applies.

Suggested fix

Have set_color (and the other text setters) update the attributed string's color attribute when the label carries an attributedStringValue, or have install_label_cell not bake a color attribute into it.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions