Page 1 of 1

#PB_Canvas_MouseX showing wrong position?

Posted: Tue Jan 08, 2013 12:06 pm
by einander
Edited to show more clearly the problem.
On this example seems that GetGadgetAttribute(0, #PB_Canvas_MouseX) shows a position
displaced a few pixels to the left of the mouse pointer.
Is my fault or a bug?
Tested on Win7 32 and 64

Code: Select all

If OpenWindow(0, 0, 0, 220, 220, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ScrollAreaGadget(1,0,0,220,220,400,220,10)
    CanvasGadget(0, 10, 10, 200, 200)
  CloseGadgetList()
  StartDrawing(CanvasOutput(0))
  Box (50,10,10,50,#Red)
  StopDrawing()
  Repeat
    Event = WaitWindowEvent()
    If Event = #PB_Event_Gadget And EventGadget() = 0 
      If  eventType() = #PB_EventType_MouseMove
        If StartDrawing(CanvasOutput(0))
          X = GetGadgetAttribute(0, #PB_Canvas_MouseX)
          Y = GetGadgetAttribute(0, #PB_Canvas_MouseY)
            SetWindowTitle(0,Str(X)+"   "+Str(Y))
          StopDrawing()
        EndIf
      EndIf
    EndIf    
  Until Event = #PB_Event_CloseWindow
EndIf

Re: #PB_Canvas_MouseX showing wrong position?

Posted: Tue Jan 08, 2013 1:23 pm
by STARGĂ…TE
no problem here: Win XP 32bit

Re: #PB_Canvas_MouseX showing wrong position?

Posted: Tue Jan 08, 2013 1:30 pm
by Josh
no problem here. Testet WIN7 Ultimate 64bit

PB 4.60 compiled 32 bit -> ok
PB 4,60 compiled 64 bit -> ok
PB 5.10 compiled 64 bit -> ok

Re: #PB_Canvas_MouseX showing wrong position?

Posted: Wed Jan 09, 2013 7:28 am
by netmaestro
Seems fine here, win7 x64 PB 5.10 final x86






...made you look! :mrgreen:

Re: #PB_Canvas_MouseX showing wrong position?

Posted: Wed Jan 09, 2013 4:21 pm
by einander
Edited the code on the firts post.
Here is a screenshot of the edited code on the first post showing the problem. (Digital photo of the screen.)
The cursor position is out of the the image.
With #PB_scrollarea_borderless the problem is the same.
win7 x32 and x64, PB 5.10
Image

Re: #PB_Canvas_MouseX showing wrong position?

Posted: Wed Jan 09, 2013 6:48 pm
by freak
If the program is slower to process events that the mouse moves, it will lag behind. this is normal. GetGadgetAttribute(0, #PB_Canvas_MouseX) gives you the mouse position at the time that the event happened not the current one.

Re: #PB_Canvas_MouseX showing wrong position?

Posted: Wed Jan 09, 2013 7:28 pm
by DoctorLove
Well, i think its not normal. Here at work we tested it with Delphi and Realbasic, and no problem there. This is a serious issue if the events are not triggered correctly in order.

Re: #PB_Canvas_MouseX showing wrong position?

Posted: Wed Jan 09, 2013 8:38 pm
by davido
I tried einander's code on my Core i3 running at about 80% load and the mouse position reported is just fine.

The response is excellent; moving the mouse makes the numbers unreadable as they are updated so quicky!
On stopping the movement of the mouse the co-ordinates are instantly correct.