Mouse problem

Just starting out? Need help? Post your questions and find answers here.
alanuk
User
User
Posts: 68
Joined: Mon Oct 13, 2003 6:38 pm

Mouse problem

Post by alanuk »

The code below doesn't work between the hash lines. I have checked the help files and I think I am doing it the way it says, but obviously I am missing something.

Can anybody help please?

Thanks

Alan



If Window_Form1()
quitForm1=0
Repeat
EventID=WaitWindowEvent()
Select EventID
Case #PB_Event_CloseWindow
If EventWindowID()=#Window_Form1
quitForm1=1
EndIf

Case #PB_Event_Gadget
Select EventGadgetID()
Case #Gadget_Form1_TrackBar3
etc etc etc
EndSelect
EndSelect
#####################################################
event=EventType()
Select event
Case #PB_EventType_LeftClick
Debug "found"
; draw
If StartDrawing(WindowOutput())
If InitMouse()
Plot(WindowMouseX(),WindowMouseY(),RGB(255,0,0))
StopDrawing()
EndIf
EndIf
EndSelect
######################################################

Until quitForm1=1
CloseWindow(#Window_Form1)
EndIf
End
GreenGiant
Enthusiast
Enthusiast
Posts: 252
Joined: Fri Feb 20, 2004 5:43 pm

Post by GreenGiant »

Dont know about the rest of your code, its hard to check without the full lot, but you dont need the InitMouse() for WindowMouseX(). The InitMouse() set of commands is normally used for games and not apps, and even then InitMouse() only needs to be called once at the start of the code.
alanuk
User
User
Posts: 68
Joined: Mon Oct 13, 2003 6:38 pm

Post by alanuk »

GreenGiant, no, it's not that, it's the fact that it doesn't get into this section. There is something wrong with the event statement, but I can't see what it is.

Alan
plouf
Enthusiast
Enthusiast
Posts: 281
Joined: Fri Apr 25, 2003 6:35 pm
Location: Athens,Greece

Post by plouf »

Eventtype() returns event happened in gadget only and not in window
(mouse click in blank window area)
at least retunr event here :wink:
if you use
EventID=#WM_LBUTTONDOWN
you can get left mouse button in window note EventID from waitwindowevent
Christos
Nico
Enthusiast
Enthusiast
Posts: 274
Joined: Sun Jan 11, 2004 11:34 am
Location: France

Post by Nico »

Code: Select all

If Window_Form1() 
  quitForm1=0 
  Repeat 
    EventID=WaitWindowEvent() 
    Select EventID 
      Case #PB_Event_CloseWindow 
        If EventWindowID()=#Window_Form1 
          quitForm1=1 
        EndIf 
        
      Case #PB_Event_Gadget 
        Select EventGadgetID() 
          Case #Gadget_Form1_TrackBar3 
            etc etc etc 
        EndSelect   
    ##################################################### 
      Case #WM_LBUTTONDOWN 
        Debug "found" 
        ; draw 
        If StartDrawing(WindowOutput()) 
          If InitMouse() 
            Plot(WindowMouseX(),WindowMouseY(),RGB(255,0,0)) 
            StopDrawing() 
          EndIf 
        EndIf 
        ###################################################### 
    EndSelect  
  Until quitForm1=1 
  CloseWindow(#Window_Form1) 
EndIf 
End
alanuk
User
User
Posts: 68
Joined: Mon Oct 13, 2003 6:38 pm

Post by alanuk »

Thanks guys, problem now solved. #WM_LBUTTONUP/DOWN did the job.

Alan
Post Reply