Dynamically changing a label text

A forum for general AmigaOS 4.x support questions that are not platform-specific
Post Reply
TomSoniq
Posts: 13
Joined: Sun Jun 19, 2011 2:03 pm

Dynamically changing a label text

Post by TomSoniq »

Hi!

I'd like to dynamically change the text in a label in both cases when the window containing that label is open and when it is closed (but the label object still exists).

From what I can see in the SDK examples, a label can have multiple elements. This means that a label can have multiple texts.
So when I just call

Code: Select all

SetAttrs(labelobj, LABEL_Text, "Some text", TAG_END);
the behaviour seems to be undetermined. Sometimes it changes the only text that's in there, sometimes it adds another one.

This is understandable. How should it know what to do?

So the question is: How do I do it right? I've got a label object which already is the child of a textedit object. But this label object contains just a single text. Can I change that text? And if yes, how?

Thanks,
Tom
User avatar
salass00
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 530
Joined: Sat Jun 18, 2011 3:12 pm
Location: Finland
Contact:

Re: Dynamically changing a label text

Post by salass00 »

The label class is not really meant to be dynamic so you might have trouble implementing that approach.

A more common way of having text that can be changed in a GUI is to use a button.gadget that is set to be transparent and borderless (no bevel) and then update its GA_Text with SetGadgetAttrs().
User avatar
thomasrapp
Posts: 310
Joined: Sat Jun 18, 2011 11:22 pm

Re: Dynamically changing a label text

Post by thomasrapp »

salass00 wrote: Sun Mar 29, 2020 1:10 pm a button.gadget that is set to be transparent and borderless (no bevel)
... and read only :)
Post Reply