Page 1 of 3
Updating listviews...
Posted: Wed Jan 24, 2024 11:48 am
by Allanon
I'm a RapaGUI beginner, and I've tried to search the forum for an aswer but nothing found
The problem I have is that I'd like to update a listview where I'm adding log entries during a long operation, the loop runs from a callback, but seems that the listview (with my added entries) is only updated when the callback returns to the main loop that listen to the events.
Any hints about making the listview update as soon as an entry has been added?
Re: Updating listviews...
Posted: Wed Jan 24, 2024 12:23 pm
by plouf
Have a
CheckEvent() in your loop ?
Examples would help
Re: Updating listviews...
Posted: Wed Jan 24, 2024 12:41 pm
by Allanon
I do have WaitEvent in the main loop and in the loop called from the callback I've tried to add a
CheckEvents() but without results.
This is piece of code of the official demo (from line 185):
Code: Select all
Case "lvaddmany":
Local c = moai.Get("listview", "entries")
If android Then moai.Set("listview", "quiet", True)
For Local k = 0 To 999 Do moai.DoMethod("listview", "insert", "bottom", "Row " .. c + k .. " item " .. "1", "Row " .. c + k .. " item " .. "2", "Row " .. c + k .. " item " .. "3")
If android Then moai.Set("listview", "quiet", False)
if you change the For/Do as following you will notice that entries are displayed all togheter when finished:
Code: Select all
For Local k = 0 To 999 Do Wait(10, #MILLISECONDS) moai.DoMethod("listview", "insert", "bottom", "Row " .. c + k .. " item " .. "1", "Row " .. c + k .. " item " .. "2", "Row " .. c + k .. " item " .. "3")
Hope this help

Re: Updating listviews...
Posted: Wed Jan 24, 2024 12:48 pm
by Allanon
I forgot to say that I'm on Linux

Re: Updating listviews...
Posted: Wed Jan 24, 2024 7:02 pm
by Allanon
After digging a bit I've tried to use the "redraw" mothod without results...
Here is a test code so you can test a simple real case:
Code: Select all
@REQUIRE "RapaGUI"
Function testFunc()
For i=1 To 100
moai.DoMethod("lv", "insert", "bottom", GetTime(True) .. ": " .. "Hello!")
moai.DoMethod("lv", "jump", "bottom")
moai.DoMethod("lv", "redraw")
Wait(20, #MILLISECONDS)
DebugPrint("Added item " .. i)
Next
EndFunction
Function msgHandler(msg)
Switch msg.action
; Parse RapaGUI events
Case "RapaGUI"
; Filter actions by attributes
Switch msg.attribute
; Check button presses
Case "Pressed"
; Check buttons
Switch msg.id
Case "go"
testFunc()
EndSwitch
EndSwitch
EndSwitch
EndFunction
moai.CreateApp([[<?xml version="1.0" encoding="iso-8859-1"?>
<application id="app">
<menubar id="menu">
<menu title="_File">
<item id="mn_about">_About...</item>
<item/>
<item id="mn_quit">_Quit</item>
</menu>
</menubar>
<window title="TEST LV" id="window" menubar="menu">
<vgroup frame="true" frametitle="Update Test">
<listview id="lv">
<column/>
</listview>
<button id="go">GO</button>
</vgroup>
</window>
</application>
]])
; listen to these events!
InstallEventHandler({
RapaGUI = msgHandler
})
; Welcome message
moai.DoMethod("lv", "insert", "bottom", GetTime(True) .. ": " .. "Hello!")
moai.DoMethod("lv", "jump", "bottom")
; Let's go!
Repeat
WaitEvent
Forever
When you push [GO] the callback function will add several lines to the Listview but they are displayed only at the end of the loop, I've added the "redraw" method to try to force a refresh but without success...
I'd like to use a listview as a log box (like in the official demo), but this behaviour does not allow me to track long loops or long operations.
Should I switch to a textview class?
Re: Updating listviews...
Posted: Wed Jan 24, 2024 7:16 pm
by Allanon
Nope... tested textview & texteditor without any joy... I smell I have to put long operations inside timed callbacks like in the official demo for Progress Bars :
Code: Select all
Case "pbsimprg":
If Not HaveObject(#INTERVAL, 1)
p_Log("Starting progress bar...")
prgbarc = 0
SetInterval(1, p_ProgressbarTimer, 100)
moai.Set("pbsimprg", "text", "Stop timer")
Else
ClearInterval(1)
moai.Set("pbsimprg", "text", "Simulate progress")
EndIf
but this overcomplicate things...
Andreas, if you're around, give it a shot!

Re: Updating listviews...
Posted: Wed Jan 24, 2024 8:56 pm
by plouf
Allanon wrote: ↑Wed Jan 24, 2024 7:02 pm
When you push [GO] the callback function will add several lines to the Listview but they are displayed only at the end of the loop, I've added the "redraw" method to try to force a refresh but without success...
I'd like to use a listview as a log box (like in the official demo), but this behaviour does not allow me to track long loops or long operations.
Should I switch to a textview class?
seems a Linux issue, under windows11 i see your example WITHOUT wait, isntantly show
check video ->
https://streamable.com/lqo8vu
Re: Updating listviews...
Posted: Thu Jan 25, 2024 9:12 am
by Allanon
plouf wrote: ↑Wed Jan 24, 2024 8:56 pm
Allanon wrote: ↑Wed Jan 24, 2024 7:02 pm
When you push [GO] the callback function will add several lines to the Listview but they are displayed only at the end of the loop, I've added the "redraw" method to try to force a refresh but without success...
I'd like to use a listview as a log box (like in the official demo), but this behaviour does not allow me to track long loops or long operations.
Should I switch to a textview class?
seems a Linux issue, under windows11 i see your example WITHOUT wait, isntantly show
check video ->
https://streamable.com/lqo8vu
Thank you for trying the sample script but the point is in the line you commented out

When you have the
Wait() command uncommented do you see the listview populate during the
for/next loop, one line at a time, or do you see all the entries at the end?

Re: Updating listviews...
Posted: Thu Jan 25, 2024 9:37 am
by plouf
Thats the point of comenting out
With commented out wait is the video
I see with or without wait filling
Re: Updating listviews...
Posted: Thu Jan 25, 2024 10:32 am
by Allanon
I see, so it's seems a Linux related problem...
I've the chance to test it on Windows 10 and yes, seems a bug
thank you for your time
