How to change a label text?

5 posts / 0 new
Last post
AmigaBlitter
AmigaBlitter's picture
Offline
Last seen: 4 years 9 months ago
Joined: 2012-02-18 19:55
How to change a label text?
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
trixie
trixie's picture
Offline
Last seen: 3 months 1 week ago
Joined: 2011-02-03 13:58
@AmigaBlitter How can i
@AmigaBlitter
How can i change the text of the label later?
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.
GA_ID, GID_LABEL,
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
AmigaBlitter
AmigaBlitter's picture
Offline
Last seen: 4 years 9 months ago
Joined: 2012-02-18 19:55
Thank you for the
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
salass00
salass00's picture
Offline
Last seen: 1 day 16 hours ago
Joined: 2011-02-03 11:27
By setting GA_ReadOnly to
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.
jabirulo
jabirulo's picture
Offline
Last seen: 2 weeks 3 days ago
Joined: 2013-05-30 00:53
You can check too, maybe they
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
Log in or register to post comments