Page 1 of 1

mouse coords off

Posted: Thu Oct 30, 2003 1:05 am
by blueznl
viewtopic.php?t=5073&highlight=mouse+offset

is this solved / not solved, or am i overlooking something?

Code: Select all

If OpenWindow(0,0,0,500,300,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"ImageGadget")
    Repeat
      UseWindow(0)
      StartDrawing(WindowOutput())
      x=WindowMouseX()
      y=WindowMouseY()
      Line(x,y,1,1,RGB(0,0,0))
      StopDrawing()
    Until WaitWindowEvent()=#PB_Event_CloseWindow 
EndIf 


Re: mouse coords off

Posted: Thu Oct 30, 2003 1:14 am
by einander
"blueznl": highlight=mouse+offset
is this solved / not solved, or am i overlooking something?
It's solved by Fred in a previous post:

Code: Select all

MX=WindowMouseX() - GetSystemMetrics_(#SM_CYSIZEFRAME)
MY=WindowMouseY() - GetSystemMetrics_(#SM_CYCAPTION) - GetSystemMetrics_(#SM_CYSIZEFRAME)

Posted: Thu Oct 30, 2003 1:19 am
by blueznl
wellllll... fred said he was planning to change the behaviour after 3.60... that's not the same as coding around :-)

Musex, Mousey, Mousek

Posted: Thu Oct 30, 2003 1:49 am
by einander
And here is a replacement for our beloved MOUSEK from GFA.
I think is better to put StartDrawing() and StopDrawing() outside of the loop.

Code: Select all

Global mx,my,mk

    Procedure mx()
        ProcedureReturn WindowMouseX() - GetSystemMetrics_(#SM_CYSIZEFRAME)
    EndProcedure
    Procedure my()
        ProcedureReturn WindowMouseY() - GetSystemMetrics_(#SM_CYCAPTION) - GetSystemMetrics_(#SM_CYSIZEFRAME)
    EndProcedure

    Procedure MK(EV)
        Select EV
            Case #WM_LBUTTONDOWN  : If MK=2: MK= 3:  Else:   MK=1:  EndIf
            Case #WM_LBUTTONUP    : If MK=3: MK=2:   Else:   MK =0 :EndIf
            Case #WM_RBUTTONDOWN  : If MK=1: MK=3 : Else :  MK=2:   EndIf
            Case #WM_RBUTTONUP    : If MK=3: MK=1:   Else :  MK=0 :  EndIf
        EndSelect
    EndProcedure

OpenWindow(0,0,0,500,300,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"ImageGadget") 
    xant=mx():yant=my()
    StartDrawing(WindowOutput()) 
    Repeat 
        Event=WaitWindowEvent()
        mk(event)
        x=mx()  : y=my() 
        If mk=1  
             LineXY(xant,yant,x,y,RGB(0,0,0)) 
        EndIf
        xant=x:yant=y
    Until Event=#PB_Event_CloseWindow 
    StopDrawing() 
End 

Posted: Thu Oct 30, 2003 2:00 am
by kenet
line is faster than plot ?

Posted: Thu Oct 30, 2003 2:02 am
by kenet
ho ok, forget it
i understand why you using line :)

Posted: Thu Oct 30, 2003 2:18 am
by einander
kenet wrote:ho ok, forget it
i understand why you using line :)
Kenet:
It's not line, it's LineXY :wink:

Posted: Thu Oct 30, 2003 9:19 am
by blueznl
yeah, for some reason plot doesn't do clipping :-) you crashed your test program :-)