I would sepearte this in a fixed text and a variable one:
Code: Select all
If OpenWindow(0, 0, 0, 300, 30, "Window mouse monitor", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
TextGadget(0, 10, 6, 150, 20, "Window mouse position: ")
TextGadget(1,160,6,100,20,"")
Repeat
Event = WaitWindowEvent(20) ; return at least every 20ms for an update
SetGadgetText(1, Str(WindowMouseX(0)) + "," + Str(WindowMouseY(0)))
Until Event = #PB_Event_CloseWindow
EndIf
or you use a read-ony borderless string-gadget
Code: Select all
If OpenWindow(0, 0, 0, 300, 30, "Window mouse monitor", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
StringGadget(0, 10, 6, 200, 20, "",#PB_String_BorderLess|#PB_String_ReadOnly)
Repeat
Event = WaitWindowEvent(20) ; return at least every 20ms for an update
SetGadgetText(0, "Window mouse position: " + Str(WindowMouseX(0)) + "," + Str(WindowMouseY(0)))
Until Event = #PB_Event_CloseWindow
EndIf
edit: or the best methode:
Code: Select all
If OpenWindow(0, 0, 0, 300, 30, "Window mouse monitor", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
TextGadget(0, 10, 6, 200, 20, "")
Define oldx,oldy,x,y
Repeat
Event = WaitWindowEvent(20) ; return at least every 20ms for an update
x=WindowMouseX(0)
y=WindowMouseY(0)
If x<>oldx Or y<>oldy
SetGadgetText(0, "Window mouse position: " + Str(x) + "," + Str(y))
oldx=x
oldy=y
EndIf
Until Event = #PB_Event_CloseWindow
EndIf
only change the text, when the coordinates have changed.