Page 1 of 1

Posted: Sun Oct 13, 2002 12:29 pm
by BackupUser
Restored from previous forum. Originally posted by PB.

I think the following event commands would be very useful:

(1) FlushEvents(type) -- Clears all type events pending. Basically
the same as doing: While WindowEvent()=type : Wend
If type is not specified, just flush all events.

(2) WaitForEvent(type) -- Wait for a specific event to happen. Basically
the same as doing: While WaitWindowEvent()type : Wend
Type is any standard event, eg. #PB_EventGadget, etc, and even a combo
of several (#PB_EventGadget|#WM_SIZE, etc).


PB - Registered PureBasic Coder

Posted: Sun Oct 13, 2002 12:53 pm
by BackupUser
Restored from previous forum. Originally posted by tranquil.

Hi PB!

Long time ago I suggested the same command WaitForEvenr(#Flags) but Fred told me that there are several problems by filtering these events.

I can confirm that issue. I use waitwindowmessage_()to check for events, dont know if waitwindowevent() do it the same way. It reports you every event on a window and does not allow to filter it.

The only think I know is to filter networkevents. (catch them or catch them not :) )

Mike

Tranquilizer/ Secretly!
http://www.secretly.de
Registred PureBasic User

Posted: Sun Oct 13, 2002 2:04 pm
by BackupUser
Restored from previous forum. Originally posted by PB.

> Long time ago I suggested the same command WaitForEvenr(#Flags) but
> Fred told me that there are several problems by filtering these events.

I don't understand what the problem is... here's how I'm currently doing
it... this example shows waiting for a keypress on the form.

Code: Select all

Procedure WaitForEvent(type)
  While WaitWindowEvent()type : Wend
EndProcedure
;
If OpenWindow(0,200,200,400,100,#PB_Window_SystemMenu,"Test")
  CreateGadgetList(WindowID())
  ButtonGadget(2,50,50,250,20,"Test")
  Repeat
    WaitForEvent(#WM_KEYDOWN) : Debug "Keypress"
  Until ev=#PB_Event_CloseWindow
EndIf

PB - Registered PureBasic Coder

Posted: Sun Oct 13, 2002 2:33 pm
by BackupUser
Restored from previous forum. Originally posted by Danilo.

PB, thats not how you should code in Windows.

While you wait for your keyboard event here,
all other events are LOST forever.
In the Windows multitasking and mutlithreading
environment you should build a complete Event-Handler
for your program.

If you really want to program this way, you
already wrote the procedure for it... :)

cya,
...Danilo

(registered PureBasic user)

Posted: Sun Oct 13, 2002 3:08 pm
by BackupUser
Restored from previous forum. Originally posted by PB.

> While you wait for your keyboard event here,
> all other events are LOST forever.

But that's what I chose to wait for... I passed the #WM_KEYDOWN flag to
the procedure because that's the ONLY event I want to wait for, so what
I've done is perfectly fine. :)

Just to clarify: The example I gave is NOT how I code my apps to wait
for a keypress! Of course that would be silly, as it wouldn't get any
other events, just like you said, Danilo. It was just an example to
show a way to wait for one specific event while ignoring all others.


PB - Registered PureBasic Coder