Responding to a Mouse-up Action

From RAD Studio
Jump to: navigation, search

Go Up to Responding to the Mouse


An Vcl.Controls.TControl.OnMouseUp event occurs whenever the user releases a mouse button. The event usually goes to the object the mouse cursor is over when the user presses the button, which is not necessarily the same object the cursor is over when the button is released. This enables you, for example, to draw a line as if it extended beyond the border of the form.

To respond to mouse-up actions, define a handler for the OnMouseUp event.

Here's a simple OnMouseUp event handler that draws a line to the point of the mouse-button release:

void __fastcall TForm1::FormMouseUp(TObject *Sender, TMouseButton Button,
	TShiftState Shift, int X, int Y) {
	Canvas->LineTo(X, Y); // draw line from PenPos to (X, Y)
}

See Also