Event Questions
BlitzMax Forums/BlitzMax Beginners Area/Event Questions
| ||
| For trial I try to write a very simple drawing program. For reasons mentioned in another post ( http://www.blitzbasic.com/Community/posts.php?topic=86218 ), I've currently my main loop like:
Repeat
Select WaitEvent()
Case KEY_ESCAPE
...
End Select
X=MouseX()
Y=MouseY()
If drawing mode, draw
If delete mode, delete
If something changed, flip
Until false
First, is it ok to mix Events and polled events? For example, I read the mouse pos with mousex(); is there any reason why I should use the CurrentEvent info instead? Then: because of this construct, partially hiding the window with another one will garbage the display (which is not refreshed, as no event came). Is there an event code like WINDOW_SHOW for this? |
| ||
| Then: because of this construct, partially hiding the window with another one will garbage the display (which is not refreshed, as no event came). Is there an event code like WINDOW_SHOW for this? Check out the events below. Best to put some of them in a hook function for immediate effect. EVENT_GADGETPAINT A Canvas Gadget needs to be redrawn EVENT_WINDOWMOVE Window has been moved EVENT_WINDOWSIZE Window has been resized EVENT_APPRESUME Application resumed And for your first question i would do it event based, but that's probably just me:) The advantage is that no cpu power is consumed when nothing happens... |
| ||
hmmm, none of those worked for my repaint problem. Looks anyway bad for simple repaint: I tried following:
Repeat
WaitEvent()
Print CurrentEvent.id
Select CurrentEvent.id
...
No event id is displayed for repaint (e.g. when another window is moved over my app window) Anotherone: EVENT_WINDOWCLOSE doesn't react when I press the window-close-cross in the window bar. Why? instead, EVENT_APPTERMINATE does. |
| ||
| Quick example: Draw something and move windows on top. Resize will clear the window. |