How do I get the icon-id of a Listview entry

Discuss GUI programming with the RapaGUI plugin here
Post Reply
User avatar
mrupp
Posts: 147
Joined: Sun Jan 31, 2021 7:44 pm
Location: Switzerland
Contact:

How do I get the icon-id of a Listview entry

Post by mrupp »

I would like to rename a listview entry. It only has 1 column, but the column has the icon="true" attribute.

Code: Select all

<listview id="myListview" notify="active">
  <column icon="true" />
</listview>
To rename, I need to pass the icon-id as a parameter to the Rename() method. To get the icon-id, I would have expected GetEntry() to return it along with the column's text value but it doesn't.

Code: Select all

moai.DoMethod("myListview", "insert", "bottom", 1, "myValue")
(...)
Local icon, value = moai.DoMethod("myListview", "GetEntry", 0)
DebugPrint(icon, value)
Output:
myValue, Nil

It that a bug or is there another way to retrieve the icon-id of Listview entry?
User avatar
airsoftsoftwair
Posts: 5443
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: How do I get the icon-id of a Listview entry

Post by airsoftsoftwair »

mrupp wrote: Sat May 22, 2021 9:27 pm It that a bug or is there another way to retrieve the icon-id of Listview entry?
No, this is a (known) limitation. Adding this would be quite some work so I decided to leave it out for the time being :)
User avatar
mrupp
Posts: 147
Joined: Sun Jan 31, 2021 7:44 pm
Location: Switzerland
Contact:

Re: How do I get the icon-id of a Listview entry

Post by mrupp »

airsoftsoftwair wrote: Sun May 23, 2021 9:23 pm No, this is a (known) limitation. Adding this would be quite some work so I decided to leave it out for the time being :)
This makes it hard to use "rename" on a listview with icons. It makes it necessary to keep track of the icons-ids of all entries in a global array. How about this: When calling the "rename" method and "Nil" is passed as a value where an icon-id is expected, it is simply ignored and the icon is left as it is?
That would already help alot and make renaming as easy as if not having icons in the column! All I'm hoping is that it's as easy to implement as it sounds... ;)
SamuraiCrow
Posts: 475
Joined: Fri May 15, 2015 5:15 pm
Location: Waterville, Minnesota USA

Re: How do I get the icon-id of a Listview entry

Post by SamuraiCrow »

It sounds like you haven't tried MOAI.UserData though I find global tables to be easier anyway.
I'm on registered MorphOS using FlowStudio.
User avatar
airsoftsoftwair
Posts: 5443
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: How do I get the icon-id of a Listview entry

Post by airsoftsoftwair »

mrupp wrote: Tue May 25, 2021 6:17 pm This makes it hard to use "rename" on a listview with icons. It makes it necessary to keep track of the icons-ids of all entries in a global array.
Okay, I'm convinced :)

Code: Select all

- New: Listview.GetEntry() accepts an optional argument now; if this is set to TRUE, Listview.GetEntry()
  will also return the identifier of the brush/icon used for a listview item or -1 if no brush/icon has
  been set for this item; note that the identifier is only returned for columns that have the "Icon" tag
  set to TRUE
Post Reply