mouseDown

mouseDown(button:  Integer;              (Form)
          shift:   Integer;
          x:       Real;
          y:       Real);

mouseDown(control: control-type input;   (Control)
          button:  Integer;
          shift:   Integer;
          x:       Real;
          y:       Real);

The mouseDown event occurs when the user presses a mouse button. The mouseDown event uses the parameters listed in the following table.

Parameter Description
button The button that was pressed to cause the event.
 
  • 1 (left button)

 
  • 2 (right button)

 
  • 3 (middle button)

shift The state of the Shift, Ctrl, and Alt keys when the mouse button was pressed. This integer is a combination of values:
 
  • To test if the Shift value (1) is set, use if shift.bitAnd(1) <> 0 then

 
  • To test if the Ctrl value (2) is set, use if shift.bitAnd(2) <> 0 then

 
  • To test if the Alt value (4) is set, use if shift.bitAnd(4) <> 0 then

x The current left physical position of the mouse pointer within the window. This is in the units of the scaleMode property of the form or control.
y The current top physical position of the mouse pointer within the window. This is in the units of the scaleMode property of the form or control.

For details about converting the horizontal (x) and vertical (y) physical pixel positions to logical positions within the window that has been scrolled, see the scrollHorzPos property.

Use a mouseDown event to specify actions to occur when a specified mouse button is pressed. Unlike the click or dblClick event, the mouseDown event enables you to distinguish between the left, right, and middle mouse buttons. If a new form is created or if focus is shifted before the mouseDown event is completed, focus is not set. You can also write logic for mouse and keyboard combinations that use the Shift, Ctrl, and Alt keyboard modifiers.

See the Window class for details of the MouseButton_ constants provided for window classes.

The following applies to both click and dblClick events.

You can use a mouseMove or mouseLeave event to respond to an event caused by moving the mouse. The button parameter for the mouseDown event differs from the button parameter used for the mouseMove event. For the mouseDown event, the button parameter indicates exactly one button for each event; for the mouseMove event, it indicates the current state of all buttons.

Table control subclasses do not reference mousePointer in a mouseDown event to determine if the mouse is in the resize position. Use the allowResize property to specify whether users can resize the rows and columns of a table. (The resizeColumn and resizeRow event methods are called when a resize operation has been performed using the mouse on a table column or row, respectively.)