ControlDragging was: Re: [lazarus] CVS Changes

Alexander Reiter r.alex at netway.at
Thu Jun 15 16:17:13 EDT 2000


sorry, find another solution:

Procedure TDesignerForm.MouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
var
  dx, dy: Integer;
begin
  //if TCOntrol(sender).dragging then
  if (FMoveCOntrol.Control = Sender) 
  then begin
    dx := X - FMoveCOntrol.X;
    dy := Y - FMoveCOntrol.Y;
    FMoveControl.Control.Left := dX;
    FMoveControl.Control.Top  := dY;
  end;
end;

...sorry for the two unnecessary emails....

br
alex

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);
> var
>   dx, dy: Integer;
> begin
>   //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;
>   end;
> end;
> 
> br
> alex
> 
> 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






More information about the Lazarus mailing list