Page 1 of 1

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

Posted: Sat May 22, 2021 9:27 pm
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?

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

Posted: Sun May 23, 2021 9:23 pm
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 :)

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

Posted: Tue May 25, 2021 6:17 pm
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... ;)

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

Posted: Sun May 30, 2021 3:59 am
by SamuraiCrow
It sounds like you haven't tried MOAI.UserData though I find global tables to be easier anyway.

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

Posted: Sun May 30, 2021 5:42 pm
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