The author of AmigaAmp found a discrepancy/bug in (what he believes) might be label.image (as child called from string.gadget).
If a (string.gadget) label gets renamed, the old name stays where it is and instead the new name is added to the end of it.
See the attached examples
In the picture you can see what happens after clicking a few times on "change".
Instead of changing the gadget label name to "string 3" it gets added to the end of "string2" (over and over again) which looks wrong.
This happens with both
label.image 53.14 and 47.5
string.gadget 53.22 and 47.22
Thank you for any pointers.
Bug in string.gadget/label.image
Bug in string.gadget/label.image
- Attachments
-
- LabelTest.lha
- (7.66 KiB) Downloaded 206 times
People are dying.
Entire ecosystems are collapsing.
We are in the beginning of a mass extinction.
And all you can talk about is money and fairytales of eternal economic growth.
How dare you!
– Greta Thunberg
Entire ecosystems are collapsing.
We are in the beginning of a mass extinction.
And all you can talk about is money and fairytales of eternal economic growth.
How dare you!
– Greta Thunberg
Re: Bug in string.gadget/label.image
Thanks Raziel for starting this thread.
Here are some more details.
What I do:
Call SetAttrs() for a label gadget with tag LABEL_Text = a new string (in this example "String _3").
What I'd expect:
The label changes from whatever it was before to "String _3".
What happens:
Each time I call SetAttrs() the string "String _3" is appended to the lebel's current text.
Can you please tell me...
Tom
Here are some more details.
What I do:
Call SetAttrs() for a label gadget with tag LABEL_Text = a new string (in this example "String _3").
What I'd expect:
The label changes from whatever it was before to "String _3".
What happens:
Each time I call SetAttrs() the string "String _3" is appended to the lebel's current text.
Can you please tell me...
- if this is a bug or a feature?
- if I'm doing something wrong?
- how to do it right?
Tom
- javierdlr
- Beta Tester
- Posts: 389
- Joined: Sun Jun 19, 2011 10:13 pm
- Location: Donostia (GUIPUZCOA) - Spain
- Contact:
Re: Bug in string.gadget/label.image
Hi, not sure if you can SetAttrs to a LABEL/CHILD object, maybe you need LM_MODIFYCHILD (layout autodocs). You can see an example in ReAction source examples Layout/dynamicexample.c
- Attachments
-
- dynamicexample_SRC.7z
- dynamicexample.c
- (2.22 KiB) Downloaded 232 times
- broadblues
- AmigaOS Core Developer
- Posts: 600
- Joined: Sat Jun 18, 2011 2:40 am
- Location: Portsmouth, UK
- Contact:
Re: Bug in string.gadget/label.image
This is correct behaviour. You build up the lines of a label by adding multiple LABEL_Text call, each can have different styles applied, or you could have, text images text etc
If you want to replsce the label, you need to remove it and add a new one. Or use an alternate approach, for example the label could be a borferless readonly string gadet, or Spa e gadet with rendethook
- broadblues
- AmigaOS Core Developer
- Posts: 600
- Joined: Sat Jun 18, 2011 2:40 am
- Location: Portsmouth, UK
- Contact:
Re: Bug in string.gadget/label.image
BTW It's a, label.image not gadget.
Images an gadgets have differing behaviours, this being one of them....
Images an gadgets have differing behaviours, this being one of them....
- thomasrapp
- Posts: 310
- Joined: Sat Jun 18, 2011 11:22 pm
Re: Bug in string.gadget/label.image
If this is true, it is bad and unintuitive design. A call to SetAttrs should always set the new value of the given attibute, replacing the old one.
If you want SetAttrs to append text to the label, then you should introduce a new tag which tells the developer what it does, for example LABEL_AppendText.
- broadblues
- AmigaOS Core Developer
- Posts: 600
- Joined: Sat Jun 18, 2011 2:40 am
- Location: Portsmouth, UK
- Contact:
Re: Bug in string.gadget/label.image
You have a valid point, and I'm not defending the design, just explaining how it worksthomasrapp wrote: ↑Fri Jul 29, 2022 1:18 pmIf this is true, it is bad and unintuitive design. A call to SetAttrs should always set the new value of the given attibute, replacing the old one.
If you want SetAttrs to append text to the label, then you should introduce a new tag which tells the developer what it does, for example LABEL_AppendText.
Problem is this image has been about for ages, the design mistake predates OS4 by some time and even if the better named new tags were added, existing software would need the old behaviour to remain.
It *is* documented.
IA_Data (CONST_STRPTR)
LABEL_Text (CONST_STRPTR)
A text string to render. A '\n' in the string will cause the
text position to move to a new line. The first underscore ('_')
in the string will be used to underline the following character
in the string. Any number of text strings and images can be
provided in a label mixed at will.
Applicability is (OM_NEW)
Actually based on the documentation phrasing, you could argue that the tags should not be accepted by OM_SET at all, and the fact that it is, is a bug.LABEL_Image (struct Image *)
An image to render. Any number of text strings and images can
be provided in a label mixed at will.
Applicability is (OM_NEW)
Personally I would not use a label for displaying dynamic content.
Re: Bug in string.gadget/label.image
Alright, good point.broadblues wrote: ↑Mon Aug 01, 2022 6:28 pm Personally I would not use a label for displaying dynamic content.
Do you think it's worth a try using two different sting gadgets, each with its own static label, and only displaying one of them while removing the other?
Thanks,
Tom
- broadblues
- AmigaOS Core Developer
- Posts: 600
- Joined: Sat Jun 18, 2011 2:40 am
- Location: Portsmouth, UK
- Contact:
Re: Bug in string.gadget/label.image
I'm not 100% sure what you are trying to do. Why do you need to change the label on the string gadget?TomSoniq wrote: ↑Tue Aug 02, 2022 9:02 amAlright, good point.broadblues wrote: ↑Mon Aug 01, 2022 6:28 pm Personally I would not use a label for displaying dynamic content.
Do you think it's worth a try using two different sting gadgets, each with its own static label, and only displaying one of them while removing the other?
Thanks,
Tom
If you have two different contexts (different file or media type perhaps?) where you need a slightly different GUI foreach one then yes, I would create two layouts, and use LM_ADDCHILD / LM_REMOVECHILD to switch them in and out. Remember to set CHILD_NoDispose to TRUE, otherwise the sublayouts will get disposed when you remove them.
I do this to display different pluging settings for the different tools in SketchBlock.