SetGadgetText gadget,text$

Parameters

gadget - gadget whose text to set

text$ - new text (UTF-8)

Description

Sets a gadget's text - a window title, a label or button caption, a field's contents.

What "text" means depends on the gadget: the title bar of a window, the caption of a label, button, group box or link label, the full contents of a text field or text area, or the number shown in a spin box. Text is UTF-8 throughout, so accented names and symbols work as-is.

Setting text from code is silent (no $401 event), and setting the same text a gadget already has is a no-op - the control is not redrawn, so you can refresh labels every frame without flicker.

Two special cases: a spin box only accepts a valid whole number (anything else stops with an "Invalid spin box value" runtime error), and on a text area this replaces the entire contents - use SetTextAreaText for partial edits.

See it working in the window and button sample.


See also: GadgetText, SetTextAreaText, SetStatusText, SetMenuText, SetGadgetToolTip.

Index