What's a good place for checking mouse events?

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by cor.

What's a good place for checking mouse events in the WaitWindowEvent loop and what type of mouse command can be used?

WaitWindowEvent loop

Repeat

Select WaitWindowEvent()

Case #PB_EventMenu

Case #PB_EventRepaint

Case #WM_CLOSE ; #PB_EventCloseWindow
Quit = 1

EndSelect

Until Quit = 1

EndIf

End



Registered user of PB

C. de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.com
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by El_Choni.

In your sample, I would put it after the rest of the event check, because some of those imply mouse events.

Bye,

El_Choni
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Manolo.
What's a good place for checking mouse events in the WaitWindowEvent loop and what type of mouse command can be used?
This is the best position:

Code: Select all

TextGadget  (12, 10, #WindowHeight-50, 250, 24, "PureBasic - Gadget demonstration")

Repeat 
  EventID.l = WaitWindowEvent()
   
 SetGadgetText(12, "x: "+Str(WindowMouseX())+", y: "+Str(WindowMouseY()))
    
    If EventID = #WM_KEYUP Or EventID = #WM_KEYDOWN
      SetGadgetText(12, "Key: "+Str(EventwParam()))
    EndIf
   If EventID = #PB_EventGadget
   Select EventGadgetID()
Regards,
Manolo
[url]mailto:vpardo@infonegocio.com[/url]
Post Reply