RosettaCodeData/Task/Mouse-position/PureBasic/mouse-position-2.purebasic

21 lines
537 B
Plaintext

#MyWindow = 0
#Label_txt = 0
#MousePos_txt = 1
If OpenWindow(#MyWindow,0,0,200,200,"Test",#PB_Window_SystemMenu)
TextGadget(#Label_txt,0,0,100,20,"Mouse Position (x,y):",#PB_Text_Right)
TextGadget(#MousePos_txt,120,0,60,20,"()")
Repeat
Repeat
event = WaitWindowEvent(10)
If event = #PB_Event_CloseWindow
Break 2 ;exit program
EndIf
Until event = 0
x = WindowMouseX(#MyWindow)
y = WindowMouseY(#MyWindow)
SetGadgetText(#MousePos_txt,"(" + Str(x) + "," + Str(y) + ")")
ForEver
EndIf