Title says it really. If I drag a GUI window around, while I'm dragging it, nothing happens. Now I can understand some events not being recognised, sure, but a timer? BlitzMax is fairly powerful, but I've yet to see any evidence it can stop time. Is there a solution/fix/workaround to this behaviour? An event I have to catch, perhaps?
If I drag a window.. timers stop?
BlitzMax Forums/BlitzMax Programming/If I drag a window.. timers stop? You need to use an eventhook as Windows goes into a "modal loop" when the window is being dragged (it can do callbacks but can't allow your main loop to execute).
Strict Type TTestApp Field Window:TGadget = CreateWindow("",0,0,640,480) Field Canvas:TGadget = CreateCanvas(0,0,ClientWidth(window),ClientHeight(window),window,PANEL_BORDER) Field Timer :TTimer = CreateTimer(10) Field Tick Method New() AddHook EmitEventHook,eventhook,Self Canvas.SetLayout(1,1,1,1) EndMethod Function eventhook:Object(id,data:Object,context:Object) If TTestApp(context) Then TTestApp(context).OnEvent TEvent(data) Return data EndFunction Method OnEvent(event:TEvent) Select event.id Case EVENT_WINDOWCLOSE Select Event.Source Case window End End Select Case EVENT_GADGETPAINT Select Event.Source Case Canvas SetGraphics(CanvasGraphics(canvas)) SetViewport(0,0,ClientWidth(canvas),ClientHeight(canvas)) Cls DrawText Tick,10,10 Flip 0 EndSelect Case EVENT_TIMERTICK Select Event.Source Case Timer Tick = Event.Data RedrawGadget(Canvas) EndSelect EndSelect EndMethod EndType Global App:TTestApp = New TTestApp While True WaitEvent() Wend
Hi,
Thanks for the example, but that doesn't work for me. Once the window starts being dragged, the canvas stops being updated.
Thanks for the example, but that doesn't work for me. Once the window starts being dragged, the canvas stops being updated.
Gabriel,
There is an example of this in the MaxGUI tutorial in the "Tutorials and articles" section of the docs.
There is an example of this in the MaxGUI tutorial in the "Tutorials and articles" section of the docs.
So there is. That example won't compile as-is, unfortunately ( apparently SetTarget is not a valid method for windows any more ) and with those lines commented out, it kinda works. There is a very long pause after you click and drag before the eventhooking kicks in, and if you press any of the minimize or maximize buttons it breaks down altogether and stops again. But it's a bit better, I suppose.
EDIT: It doesn't work when integrated into my project though. It may work for simple stuff, but that seems to be all.
EDIT: It doesn't work when integrated into my project though. It may work for simple stuff, but that seems to be all.