ControlDragging was: Re: [lazarus] CVS Changes
SMiller1 at stvgb.org
Thu Jun 15 16:34:57 EDT 2000
I think I have it working correctly if I get the right coord's for the parent.
The problem with using X and Y are that you don't ever know if they are X and Y relative to the control (if you move only one pixel up, the mouse is still within the control) or if the X and Y are relative to the parent.
If you select a middle of the button and you get your x and y of 12,5, you can move off the mouse (with the button down) and you'll start seeing other X and Y coord's that are associated with the form.
I think we need to fix this issue and then it will work.
P.S. There are no unnecessary emails as long as you are trying to help. Keep sending ideas.
>>> r.alex at netway.at 06/15/00 03:17PM >>>
sorry, find another solution:
Procedure TDesignerForm.MouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
dx, dy: Integer;
//if TCOntrol(sender).dragging then
if (FMoveCOntrol.Control = Sender)
dx := X - FMoveCOntrol.X;
dy := Y - FMoveCOntrol.Y;
FMoveControl.Control.Left := dX;
FMoveControl.Control.Top := dY;
...sorry for the two unnecessary emails....
Alexander Reiter wrote:
> i think the problem is in TDesignerForm.MouseMove.
> if you try this, you can move your control. well is not the
> best solution, but it is a good starting point. take a look
> at this:
> Procedure TDesignerForm.MouseMove(Sender: TObject; Shift: TShiftState;
> X, Y: Integer);
> dx, dy: Integer;
> //if TCOntrol(sender).dragging then
> if (FMoveCOntrol.Control = Sender)
> then begin
> WriteLn(Format('[TDesignerForm.MouseMove] Start(%d, %d) Stop(%d,
> %d)', [FMoveCOntrol.X, FMoveCOntrol.Y, X, Y]));
> not correct --> //dx := X - FMoveCOntrol.X;
> not correct --> //dy := Y - FMoveCOntrol.Y;
> dx := X - FMoveControl.Control.Left;
> dy := Y - FMoveControl.Control.Top;
> FMoveControl.Control.Left := FMoveControl.Control.Left + dX;
> FMoveControl.Control.Top := FMoveControl.Control.Top + dY;
> Marc Weustink wrote:
> > At 13:30 14-06-2000 -0500, Shane Miller wrote:
> > >Press the NEW FORM button.
> > >Select the Button component and drop it onto the form.
> > >Drag the button 2 pixels up. It probably moved a little. Now do it again.
> > >It doesn't work.
> > >If you look at the output (look at designerform.pp in mousedown and mouseup
> > >to see what SHOULD be displayed) you'll see that the TOP and LEFT seem to
> > >be reported incorrectly.
> > >If you MOVE the form then try it again it's reported correctly.
> > >This also occurs when trying to place controls onto the form. Sometimes
> > >they appear correctly, sometimes not.
> > >When they dont you can move the form and thn the next one appears
> > >correctly.
> > >
> > >Any ideas?
> > Mouse.Cursorpos is given in screen coordinates, not in form coordinates.
> > Onmousedown you store Cursorpos (or better, the given X and Y),
> > onmouseUp you calc the difference with the new Cursorpos (or better, the
> > given X and Y) THe difference is added to the Left and Top.
> > I committed a solution which normally should work, however it doesn't due
> > to a bug in the MouseMove and MouseUp handlers
> > MouseMove / MouseUp should always give the mouseposition X and Y in the
> > Sender coordinates. It does as long as the up event occoured in the
> > control itself. However if you are outside the control you get the X and Y
> > in Form coordinates.
> > Marc
> > _________________________________________________________________
> > To unsubscribe: mail lazarus-request at miraclec.com with
> > "unsubscribe" as the Subject
> > archives at http://www.miraclec.com/list_archives/lazarus
> To unsubscribe: mail lazarus-request at miraclec.com with
> "unsubscribe" as the Subject
> archives at http://www.miraclec.com/list_archives/lazarus
To unsubscribe: mail lazarus-request at miraclec.com with
"unsubscribe" as the Subject
archives at http://www.miraclec.com/list_archives/lazarus
More information about the Lazarus