mouse x y canvas update loop

Windows specific forum
ehowington
Enthusiast
Enthusiast
Posts: 117
Joined: Sat Sep 12, 2009 3:06 pm

mouse x y canvas update loop

Post by ehowington »

trying to figure out how to update a text gadget to display the x y when entering the canvas of the mouse postion within the canvas as a thread perhaps???

any ideas suggestions?
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: mouse x y canvas update loop

Post by IdeasVacuum »

Like This?

Code: Select all

Enumeration
  #GADGET_Canvas
  #GADGET_Text
EndEnumeration


If OpenWindow(0, 0, 0, 500, 400, "Canvas XY", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

  CanvasGadget(#GADGET_Canvas, 10, 10, 380, 380, #PB_Canvas_ClipMouse)
    TextGadget(#GADGET_Text, 400, 10, 80, 20,"")


  SetGadgetAttribute(#GADGET_Canvas, #PB_Canvas_Cursor, #PB_Cursor_Cross)

  Repeat
       Event = WaitWindowEvent()
    If Event = #PB_Event_Gadget

            Select EventGadget()

                   Case #GADGET_Canvas

                                X = GetGadgetAttribute(#GADGET_Canvas, #PB_Canvas_MouseX)
                                Y = GetGadgetAttribute(#GADGET_Canvas, #PB_Canvas_MouseY)
                                         SetGadgetText(#GADGET_Text,"X" + Str(X) + " Y" + Str(Y))
            EndSelect

    EndIf

  Until Event = #PB_Event_CloseWindow

EndIf

End
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
ehowington
Enthusiast
Enthusiast
Posts: 117
Joined: Sat Sep 12, 2009 3:06 pm

Re: mouse x y canvas update loop

Post by ehowington »

ty ty ;)
Post Reply