[Gambas-user] Cursor.X, Cursor.Y example

Demosthenes Koptsis demosthenesk at gmail.com
Tue Aug 1 20:00:57 CEST 2023


ok my mistake, the next code is working fine

----------------------------------------

' Gambas class file

Public Sub Form_MouseMove()

   Label1.Text = "Mouse X:" & Mouse.X
   Label2.Text = "Mouse Y:" & Mouse.Y

End

----------------------------------------




On 8/1/23 19:47, T Lee Davidson wrote:
> On 8/1/23 08:43, Demosthenes Koptsis wrote:
>> But i get error "Cursor.X is not Static"
>>
>> How must i write the example code
>>
>> i want to show inside Labels the position of cursor X,Y
>
> By your last sentence, do you mean you want to show the X and Y 
> coordinates of the *mouse* cursor?
>
> Mouse.X and Mouse.Y will give you the coordinates of the mouse cursor 
> relative to the top, left corner of the Form when used in the 
> Form_MouseMove event handler. Mouse.ScreenX and Mouse.ScreenY, 
> available at any time and not just within a MouseMove event, will give 
> you the coordinates of the mouse cursor relative to the top, left 
> corner of the entire screen.
>
> The X and Y properties of the Cursor class are dynamic and not static. 
> To use them, you would need to create a new Cursor object from the 
> Cursor class (https://gambaswiki.org/wiki/comp/gb.qt4/cursor/_new). 
> But, I think this is not what you want because those properties 
> represent only the X and Y coordinates of the hot spot of your custom 
> cursor. They do not give the position of the mouse cursor.
>
>


More information about the User mailing list