Vanilla question: enable() doesn't work for TextBox

Hello, not quite sure where to ask this, but I figured a forum full of vanilla library users would be a good bet. I have a question for the TextBox class: somehow, the enable() function doesn’t seem to do anything. With other elements like Button and EditText it works fine and the element is greyed out. enable() is listed in the documentation for TextBox. Anybody know whether this is the intended behaviour? Is there a different way of greying out text with vanilla? Thanks a lot!

It should work.
I would check what the enable method on textbox is doing in the vanilla source.

TextBox is a VanillaBaseControl:

which is a VanillaBaseObject:

which has an enable(onOff) method:

So it should work!?

…but it doesn’t visually change anything. Other elements get greyed out when I call that method for them, but not TextBox. Can you try in the Glyphs macro window? Maybe my installation is outdated.

Can you post a small sample script?

w = vanilla.FloatingWindow((100, 40), "Title")
w.text = vanilla.TextBox((10, 10, -10, -10), "Text")
w.text.enable(False)
w.open()

It doesn’t seem to be an issue with vanilla. I just tried it in Interface Builder. Only if the field is set to “editable”, that the “enabled” flag makes a visual difference.

So you have to “fake” it by assigning a gray color.

import vanilla
from AppKit import NSColor
w = vanilla.FloatingWindow((100, 40), "Title")
w.text = vanilla.TextBox((10, 10, -10, -10), "Text")
w.text.enable(False)
w.text._nsObject.setTextColor_(NSColor.tertiaryLabelColor())
w.open()
1 Like

Thank you very very very much, as always!