Autogenerated brush ID incompatible with Listview.Insert?
Posted: Sun May 23, 2021 11:20 am
I'm having a listview and would like to dynamically load brushes and add them to my list (don't worry about memory consumption, they are not that many, should be < 10).
Now, as long as I choose the brush IDs myself, this is working fine, but if I let LoadBrush() autogenerate the brush identifier, calling the Listview's "insert" method generates an error. According to the docs, passing Nil as first parameter to LoadBrush() should return the new id, shouldn't it?
Here's an example:
Please note that you need to copy "ok.png" from the RapaGUI-Demo-script into the same directory for the example to work.
This is the error I get:
Error in line 12 (LoadBrush.hws): Number expected in argument 4!
And this is the output from DebugPrint("autoid", autoid):
autoid UserData: 00000000031EC840
Is this a bug or what am I missing?
Doing the same thing on a normal Hollywood window using DisplayBrush() works fine, so this seems a Listview.insert issue, I guess...
Now, as long as I choose the brush IDs myself, this is working fine, but if I let LoadBrush() autogenerate the brush identifier, calling the Listview's "insert" method generates an error. According to the docs, passing Nil as first parameter to LoadBrush() should return the new id, shouldn't it?
Here's an example:
Code: Select all
@REQUIRE "RapaGUI", { Link = True }
Function p_EventFunc(msg)
Switch msg.id
Case "btn1":
Local id = 1
LoadBrush(id, "ok.png", { LoadAlpha = True })
moai.DoMethod("myListview", "insert", "bottom", id, "myValue")
Case "btn2":
Local autoid = LoadBrush(Nil, "ok.png", { LoadAlpha = True })
DebugPrint("autoid", autoid)
moai.DoMethod("myListview", "insert", "bottom", autoid, "myValue")
EndSwitch
EndFunction
InstallEventHandler({RapaGUI = p_EventFunc})
moai.CreateApp([[<?xml version="1.0" encoding="iso-8859-1"?>
<application id="app">
<window id="mainWindow" title="LoadBrush-Test">
<vgroup>
<button id="btn1">Add entry with fixed brush ID</button>
<button id="btn2">Add entry with autogenerated ID</button>
<listview id="myListview">
<column icon="true" />
</listview>
</vgroup>
</window>
</application>
]])
Repeat
WaitEvent
ForeverThis is the error I get:
Error in line 12 (LoadBrush.hws): Number expected in argument 4!
And this is the output from DebugPrint("autoid", autoid):
autoid UserData: 00000000031EC840
Is this a bug or what am I missing?
Doing the same thing on a normal Hollywood window using DisplayBrush() works fine, so this seems a Listview.insert issue, I guess...
Code: Select all
Local autoid = LoadBrush(Nil, "ok.png", { LoadAlpha = True })
DebugPrint("autoid", autoid)
DisplayBrush(autoid, "100", "100")
Repeat
WaitEvent
Forever