#PB_Canvas_MouseX showing wrong position?

Just starting out? Need help? Post your questions and find answers here.
User avatar
einander
Enthusiast
Enthusiast
Posts: 744
Joined: Thu Jun 26, 2003 2:09 am
Location: Spain (Galicia)

#PB_Canvas_MouseX showing wrong position?

Post 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
Last edited by einander on Wed Jan 09, 2013 3:59 pm, edited 1 time in total.
User avatar
STARGÅTE
Addict
Addict
Posts: 2235
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: #PB_Canvas_MouseX showing wrong position?

Post by STARGÅTE »

no problem here: Win XP 32bit
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Re: #PB_Canvas_MouseX showing wrong position?

Post 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
sorry for my bad english
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: #PB_Canvas_MouseX showing wrong position?

Post by netmaestro »

Seems fine here, win7 x64 PB 5.10 final x86






...made you look! :mrgreen:
BERESHEIT
User avatar
einander
Enthusiast
Enthusiast
Posts: 744
Joined: Thu Jun 26, 2003 2:09 am
Location: Spain (Galicia)

Re: #PB_Canvas_MouseX showing wrong position?

Post 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
freak
PureBasic Team
PureBasic Team
Posts: 5944
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: #PB_Canvas_MouseX showing wrong position?

Post 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.
quidquid Latine dictum sit altum videtur
DoctorLove
User
User
Posts: 85
Joined: Sat Mar 06, 2010 2:55 pm

Re: #PB_Canvas_MouseX showing wrong position?

Post 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.
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

Re: #PB_Canvas_MouseX showing wrong position?

Post 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.
DE AA EB
Post Reply