hello,
I have a label defined in this way:
LAYOUT_AddImage, gadgets[GID_LABEL] = IIntuition->NewObject(LabelClass, NULL,
GA_ID, GID_LABEL,
LABEL_Text, "Description label - bla bl bla bla",
How can i change the text of the label later?
Thank you
@AmigaBlitter
Labels are images, not gadgets. BOOPSI images are normally "fixed content", so if you plan to modify the label text later, you may be better off making it a button.gadget instead, with BUTTON_BevelStyle set to BVS_NONE (this will draw an "invisible" button, i.e. one without a box). Then you can easily change the text via SetGadgetAttrs().
Alternately (DISCLAIMER: never tried this solution in my own code so it's just theory), if you want/need to stay with a label.image, you can try calling the IM_ERASE method (thus erasing the current label), setting a new LABEL_Text via SetAttrs(), and then calling the IM_DRAW method upon the image object. As labels are not gadgets, you need to handle the erasing and redrawing all yourself.
This line will have no effect. As the GA_ prefix implies, this is a gadget attribute so it only applies to gadget objects, whereas you're defining an image object here. Images need no IDs.
AmigaOne X5000-020 / 2GB RAM / Sapphire Pulse Radeon RX 560 / AmigaOS 4.1 Final Edition Update 2
Thank you for the explaination.
Could you please point me to an example code for both cases?
in the end i used the IGraphics->Text to write text on the window.
this should allow me to change the text as needed, but raises up some new questions.
The first: how can i set the correct lenght of the text each time i need to change?
second: should i clear the rport each time i write new text?
third: there a way for the IGraphics->Text to accept the newline charcode \n?
fourth: How to change the font and there is a new method for this?
Thank you
By setting GA_ReadOnly to TRUE, BUTTON_BevelStyle to BVS_NONE and BUTTON_Transparent to TRUE you can create a read-only button.gadget which acts as a label which you can change the text of.
To change the text of the button just call IIntuition->SetGadgetAttrs() with GA_Text.
BUTTON_DomainString can be used to reserve the space you need for your label texts.
You can check too, maybe they are of some help.
os4depot ReAction examples 1
os4depot ReAction examples 2
AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P