Differenze tra le versioni di "Spostare con il mouse un cerchio in una DrawingArea"
Da Gambas-it.org - Wikipedia.
(Creata pagina con "Nel seguente esempio si potrà spostare con il mouse sulla superficie di una ''DrawingArea'' un cerchio precedentemente disegnato. Private Const RAGGIO As Float = 50.0 Priva...") |
|||
Riga 1: | Riga 1: | ||
− | Nel seguente esempio si potrà spostare con il mouse sulla superficie di una ''DrawingArea'' un cerchio precedentemente disegnato. | + | Nel seguente esempio si potrà spostare con il mouse sulla superficie di una ''DrawingArea'' un cerchio precedentemente disegnato. <SUP>[[[#Note|Nota 1]]]</sup> |
Private Const RAGGIO As Float = 50.0 | Private Const RAGGIO As Float = 50.0 | ||
Private x As Short = 100 | Private x As Short = 100 | ||
Private y As Short = 100 | Private y As Short = 100 | ||
− | Private difx As Short | + | Private difx As Short = -1 |
Private dify As Short | Private dify As Short | ||
Riga 47: | Riga 47: | ||
'''End''' | '''End''' | ||
+ | |||
+ | |||
+ | |||
+ | =Note= | ||
+ | [1] Vedere anche: | ||
+ | <BR> - [[Spostare_con_il_mouse_un_rettangolo_in_una_DrawingArea|Spostare con il mouse un rettangolo in una DrawingArea]] | ||
+ | <BR> - [[Spostare_con_il_mouse_un'immagine_in_una_DrawingArea|Spostare con il mouse un'immagine in una DrawingArea]] |
Versione delle 01:44, 28 nov 2021
Nel seguente esempio si potrà spostare con il mouse sulla superficie di una DrawingArea un cerchio precedentemente disegnato. [Nota 1]
Private Const RAGGIO As Float = 50.0 Private x As Short = 100 Private y As Short = 100 Private difx As Short = -1 Private dify As Short Public Sub DrawingArea1_MouseDown() ' Verifica se il punto ove si è cliccato con il mouse non è esterno alla circonferenza: If Sqr(((Mouse.X - x) ^ 2) + ((Mouse.Y - y) ^ 2)) > RAGGIO Then Return difx = x - Mouse.X dify = y - Mouse.Y End Public Sub DrawingArea1_MouseMove() ' Se il punto, ove si è cliccato con il mouse è esterno alla circonferenza, allora la variabile "difx" non ha cambiato il valore assegnatogli dall'ultimo Evento "_MouseUp()": If difx == -1 Then Return x = Mouse.X + difx y = Mouse.Y + dify With DrawingArea1 .Mouse = 18 .Refresh End With End Public Sub DrawingArea1_MouseUp() difx = -1 DrawingArea1.Mouse = Mouse.Default End Public Sub DrawingArea1_Draw() With Paint .Arc(x, y, RAGGIO, Rad(0), Rad(360), False) .stroke .end End With End
Note
[1] Vedere anche:
- Spostare con il mouse un rettangolo in una DrawingArea
- Spostare con il mouse un'immagine in una DrawingArea