Chooser gadget [ SOLVED ]

7 posts / 0 new
Last post
Massi
Massi's picture
Offline
Last seen: 2 years 10 months ago
Joined: 2012-03-28 17:16
Chooser gadget [ SOLVED ]
Hello everyone! I can' t get the selected label of a chooser gadget (labels loaded as an Exec list). Any help? Thanks, regards Massi
thomas
thomas's picture
Offline
Last seen: 2 weeks 1 day ago
Joined: 2011-05-16 14:23
struct Node *node;ULONG which
  1. struct Node *node;
  2. ULONG which = 0;
  3. GetAttr (CHOOSER_Selected,object,&which);
  4. for (node = GetHead(labels); node; node = GetSucc(node))
  5. {
  6. if (which == 0)
  7. break;
  8. which --;
  9. }
  10. if (node)
  11. {
  12. char *label = NULL;
  13. GetChooserNodeAttrs (node,CNA_Text,&label,TAG_END);
  14. if (label)
  15. Printf ("%s\n",label);
  16. }
salass00
salass00's picture
Offline
Last seen: 1 month 3 weeks ago
Joined: 2011-02-03 11:27
@thomas Using
@thomas Using CHOOSER_SelectedNode (available in chooser.gadget >= 52.5) your code can be shortened to:
  1. struct Node *node = NULL;
  2. GetAttr (CHOOSER_SelectedNode,object,(Tag *)&node);
  3. if (node) {
  4. char *label = NULL;
  5. GetChooserNodeAttrs (node,CNA_Text,&label,TAG_END);
  6. if (label)
  7. Printf ("%s\n",label);
  8. }
thomas
thomas's picture
Offline
Last seen: 2 weeks 1 day ago
Joined: 2011-05-16 14:23
I thought so, but it's not
I thought so, but it's not mentioned in 3.9 autodocs ;-)
Massi
Massi's picture
Offline
Last seen: 2 years 10 months ago
Joined: 2012-03-28 17:16
Thanks guys, I will fix my
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?
salass00
salass00's picture
Offline
Last seen: 1 month 3 weeks ago
Joined: 2011-02-03 11:27
@thomas Why don't you have
@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.
  1. struct Node *node = NULL;
  2. if (ChooserBase->lib_Version > 52 ||
  3. (ChooserBase->lib_Version == 52 &&
  4. ChooserBase->lib_Revision >= 5))
  5. {
  6. GetAttr (CHOOSER_SelectedNode,object,(uint32 *)&node);
  7. } else {
  8. uint32 which = 0;
  9. GetAttr (CHOOSER_Selected,object,&which);
  10. for (node = GetHead(labels); node; node = GetSucc(node)) {
  11. if (which == 0) break;
  12. which--;
  13. }
  14. }
  15. if (node) {
  16. char *label = NULL;
  17. GetChooserNodeAttrs (node,CNA_Text,&label,TAG_END);
  18. if (label) Printf ("%s\n",label);
  19. }
Massi
Massi's picture
Offline
Last seen: 2 years 10 months ago
Joined: 2012-03-28 17:16
Thank you all! Source code
Thank you all! Source code fixed and application released on OS4Depot, project name: NetSpeedometer.
Log in or register to post comments