How to force a gadget to refresh?

Started by GW, July 09, 2017, 01:43:49

Previous topic - Next topic

GW

Anyone know how to make a gadget refresh in maxgui?  Im looping over some data and adding some things to a textarea.
Even with calling pollsystem(), the app will stop updating and the title bar will add the words (not responding).
When doing Gui apps in dotNet you can call a function called Application.DoEvents() to make the gui refresh.
Is there something equivalent for maxgui?


 

degac

Not at the computer at the moment, but RefreshGadget() should do the job.
I can check (later)
If there's a problem, there's at least one solution.
www.blitzmax.org

TomToad

I think you are looking for PollEvent().  What happens is that while you are looping over the data, events are not being processed, and when the queue is filled up, you get a (not responding).  I tried out PollEvent() in an example and the program kept running fine, but when I clicked on anything, suck as the x on top, then I got a (not responding) so it fixed only half the problem.
SuperStrict

Import maxgui.drivers

Global MainWindow:TGadget = CreateWindow("Hello",50,50,640,480)
Global TextArea:TGadget = CreateTextArea(0,0,ClientWidth(MainWindow),ClientHeight(MainWindow)-100,MainWindow)
Global AddButton:TGadget = CreateButton("Add",0,ClientHeight(MainWindow)-100,ClientWidth(MainWindow),100,MainWindow)
AddHook EmitEventHook,Hook

Repeat
WaitEvent()
Forever

Function Hook:Object(id:Int,data:Object,context:Object)
Local Event:TEvent = TEvent(data)

Select Event.id
Case EVENT_WINDOWCLOSE, EVENT_APPTERMINATE
End
Case EVENT_GADGETACTION
DoAdd()
End Select
End Function

Function DoAdd()
SetTextAreaText TextArea,""

For Local x:Int = 0 To 100000000
AddTextAreaText TextArea,x+" "
If Not(x Mod 10)Then AddTextAreaText TextArea,"~n"
Repeat
Until Not PollEvent()
Next
End Function
------------------------------------------------
8 rabbits equals 1 rabbyte.

degac

Ah, understood the problem, but I think it's something by design in MaxGUI/OS.
One solution (not tested on all platforms) is to bypass the normal behaviour using

Textarea.LockText() and TextArea.UnlockText() before and after adding/changing the text.

This will be faster, and you still have 'control' of the window, but there's no 'interaction' (=you don't see any update in the textarea gadget until the call of UnLockText() method).
If there's a problem, there's at least one solution.
www.blitzmax.org

GW

Thanks for the help guys!
Pollsystem seems reduce the problem by about 70%. I tried lock/unlocktextarea and that seems to improve it too, but it scrolls the textarea back to the top. My textarea is a logging window, so i need to always scrolled at the bottom.
I'm calling it good enough.
Thanks!