[Gambas-user] User control disappears when moved by mouse
bsteers4 at gmail.com
Tue Jun 13 00:40:39 CEST 2023
On Mon, 12 Jun 2023 at 23:31, Bruce Steers <bsteers4 at gmail.com> wrote:
> On Mon, 12 Jun 2023 at 17:01, Claus Dietrich <claus.dietrich at freenet.de>
>> When I move a user control (.i.e. a button ) on its form with following
>> Public Sub Button1_MouseMove()
>> If Mouse.left = True Then
>> Button1.Move(Mouse.screenx - Mouse.startx + Mouse.X, Mouse.Screeny
>> - Mouse.StartY + Mouse.y)
>> End If
> The problem is you are using Mouse.ScreenX not Button1.X as the first value
> The button x pos moves relevant to itself not Mouse.screenx.
> Try this... (I used Last not Button1 as then this code works to move any
> Public Sub Button1_MouseMove()
> If Mouse.Left Then Last.Move(Last.X + (Mouse.X - Mouse.StartX), Last.Y +
> (Mouse.Y - Mouse.StartY))
So to clarify...
the calculation (Mouse.X - Mouse.StartX) is a positive or negative
distance value depending where the mouse moved to horizontally.
So Button1.X += (Mouse.X - Mouse.StartX) moves horizontally with the mouse.
Button1.Y += (Mouse.Y - Mouse.StartY) does the vertical.
Hope that helps
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the User