Hi,
I am trying to get the text of the selected element of the listbrowser but I can only get the last element of the list..
This is the list of the listbrowser gadget:
CONST_STRPTR nodetexts[] = { "rastan", "outrun", "vigilante", "shinobi", NULL }; STRPTR lb_selected; // var to store selected item
and this is the piece of code that I use to get the selected item:
case OID_BSTART: IListBrowser->GetListBrowserNodeAttrs((struct Node *)node, LBNA_Column,0, //LBNA_Selected, TRUE, LBNCA_Text,&lb_selected, TAG_DONE); IDOS->Printf("listbrowser element:%s\n",lb_selected); break;
If I try to put LBNA_Selected, TRUE, I get a GR when I press the OID_BSTART gadget..
With the code above i always get the last element of the list that is "shinobi".
In my gui I have only one listcolumn.
Am I missing some tag inside the GetListBrowserNodeAttrs or do I have to put some loop code to check what the user is selecting??
Thanks
Try to get selectednode first (example is when double clicked on listbrowser entry):
and then the items/values you want/need:
AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P
Hi Jabirulo!
Thanks for the help! I was able to discover two more my mistake I did with listbrowser object. I forgot to put
tag inside the NewObject() function so this was my first mystake and that's why it cannot get the event inside the listbrowser object.
Then, using your code I was able to get the name of the selected item.
Thank you, problem solved! :-)
is it possible to mark the question as "Solved"?
@Nube
You'll need to edit the title of this thread.
AmigaOne X5000-020 / 2GB RAM / Sapphire Pulse Radeon RX 560 / AmigaOS 4.1 Final Edition Update 2
Thanks Trixie :-)
No one seems to have addressed this point.
The problem with this is that you are attempting to SET the attribute to TRUE in a GET function. What this means in practice is that the browser attempts to write the value of the selected state into the int32 pointed to by the address 0x00000001 (ie TRUE taken as an address). This will inevitably crash.
I suppose there is some confusion created by the fact you can set LBNA_Column to select which column attrs to fetch, this the only tag where you can do this. (And prety horrid design if you think about logically, but it is what it is).
Thanks broadblues, you are totally right, I didn't see this big error! i was trying to Set a TagItem using the Get function!!!...
Again thank you :-)