Hello everyone! I can' t get the selected label of a chooser gadget (labels loaded as an Exec list). Any help?
Thanks, regards
Massi
struct Node *node;ULONG which = 0;GetAttr (CHOOSER_Selected,object,&which);for (node = GetHead(labels); node; node = GetSucc(node)) { if (which == 0) break; which --; }if (node) { char *label = NULL; GetChooserNodeAttrs (node,CNA_Text,&label,TAG_END); if (label) Printf ("%s\n",label); }
@thomas
Using CHOOSER_SelectedNode (available in chooser.gadget >= 52.5) your code can be shortened to:
struct Node *node = NULL;GetAttr (CHOOSER_SelectedNode,object,(Tag *)&node);if (node) { char *label = NULL; GetChooserNodeAttrs (node,CNA_Text,&label,TAG_END); if (label) Printf ("%s\n",label);}
I thought so, but it's not mentioned in 3.9 autodocs ;-)
Thanks guys, I will fix my code. One of my goals is to keep my software as much compatible as possible, say AOS 4.0 as a minimum requirement. 52.0 means AOS 4.0, right?
Why don't you have 4.1 autodocs? They're in the SDK which is free to download from hyperion-entertainment.biz...
@Massi
Version numbers 50-52 are AmigaOS 4.0, version 53 is AmigaOS4.1.
If backwards compatibility is a big deal for you, you can always add a version check and use thomas' version if it's too old.
struct Node *node = NULL;if (ChooserBase->lib_Version > 52 || (ChooserBase->lib_Version == 52 && ChooserBase->lib_Revision >= 5)){ GetAttr (CHOOSER_SelectedNode,object,(uint32 *)&node);} else { uint32 which = 0; GetAttr (CHOOSER_Selected,object,&which); for (node = GetHead(labels); node; node = GetSucc(node)) { if (which == 0) break; which--; }}if (node) { char *label = NULL; GetChooserNodeAttrs (node,CNA_Text,&label,TAG_END); if (label) Printf ("%s\n",label);}
Thank you all! Source code fixed and application released on OS4Depot, project name: NetSpeedometer.
@thomas
Using CHOOSER_SelectedNode (available in chooser.gadget >= 52.5) your code can be shortened to:
I thought so, but it's not mentioned in 3.9 autodocs ;-)
Thanks guys, I will fix my code.
One of my goals is to keep my software as much compatible as possible, say AOS 4.0 as a minimum requirement.
52.0 means AOS 4.0, right?
@thomas
Why don't you have 4.1 autodocs? They're in the SDK which is free to download from hyperion-entertainment.biz...
@Massi
Version numbers 50-52 are AmigaOS 4.0, version 53 is AmigaOS4.1.
If backwards compatibility is a big deal for you, you can always add a version check and use thomas' version if it's too old.
Thank you all!
Source code fixed and application released on OS4Depot, project name: NetSpeedometer.