I just ran across a possible problem. I was trying to debug an application that puts up a pie chart. I wanted to track the ArcShape data so I set up a listbox and tried to populate it from the Canvas’s Paint event. However, while the data is getting to the listbox, it isn’t being displayed. So I put a Listbox1.Invalidate at the end of the Paint event but that didn’t help. What did cause the Listbox to display its contents is a Refresh of Invalidate from somewhere outside of the Canvas’s Paint event.
FD: Windows 10, Xojo 2019r3.1
i think if you add data to a listbox it will update itself as soon the event loop continue.
i made a test and it seems it is not the case. the data are there but the refresh was missing or it shows white on white.
seems adding data to others controls from within a paint event make trouble.
the event loop run if you are not in a method.
.refresh should force a redraw of a control. usually u not need this.
be sure the Invalidate is not called in a loop, as example MouseDrag.
as workaround use a TextArea
[code]Sub Paint(g As Graphics, areas() As REALbasic.Rect) Handles Paint
For i As Integer = 1 To 10
TextArea1.AddText Str(i) + EndOfLine
This looks like an undesired side effect/bug of the anti paint recursion protection introduced in 2019r2 feedback://showreport?report_id=55615 as it works as expected in 2019r1.1
Here’s a quick workaround https://www.dropbox.com/s/sj5msknke7ledbv/Bug59732.xojo_binary_project?dl=0 to get you going until its fixed.
I just updated the code a little, it only needs an invalidate that is outside the framework and thus outside the anti paint recursion check to update the listbox.
[quote=483520:@JulianS]This looks like an undesired side effect/bug of the anti paint recursion protection introduced in 2019r2 feedback://showreport?report_id=55615 as it works as expected in 2019r1.1
Here’s a quick workaround Dropbox - File Deleted to get you going until its fixed.[/quote]
Thanks, Julian, but a Windows Declare like you used isn’t very cross-platform. I think a better workaround is to move the entire Paint event code to a method and instead of drawing to the canvas, draw to a Picture that the Canvas’s graphics can draw. That moves the listbox stuff out of the paint event and everything works properly.
That being said, how often does anyone not in the process of debugging code need to populate a Listbox in a Canvas’s paint event? In my years of RB/Xojo coding this is the first time I’ve ever needed to. Although I filed the bug report, as a retired QA engineer that’s what I do, I wouldn’t give it a very high “fix” rating unless Xojo investigation it finds that it is merely the top of a bad iceberg.
I think its a windows only issue? I tried your demo on mojave with 2019r3.1 and didnt see the problem. But yes, move the code outside the paint, always better