TCustomGrid.MouseDown procedure
Handles mouse down events for the grid control.
Declaration
procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
X: Integer; Y: Integer); overrideArguments
Button | Mouse button for the event. |
Shift | Shift state for the event. |
X | Horizontal coordinate for the mouse event. |
Y | Vertical coordinate for the mouse event. |
Description
MouseDown is overridden in
TCustomGrid to ensure that
cached grid information in
GCache is updated for mouse down
events, and both GridState and GridFlags are updated for the control.
MouseDown calls the inherited method to handle focus changes for the control and drag operations. The OnMouseDown event handler is signalled (when assigned) by the ancestor class.
No additional actions are performed in the method at design-time, when the mouse Button is not allowed in the grid control, or when the control cannot receive focus.
MouseDown ensures that the grid control is focused when visible and enabled, and does not contain csNoFocus in the ControlStyle flags. MouseDown updates GCache with the coordinates for the mouse down event. The grid "hot" zone in the cached information determines the value assigned to GridState, GridFlags, CursorState and the actions performed for the mouse event.
gzFixedCells
Sets GridState to gsColSizing when both goColSizing and goFixedColSizing have been included in the Options and the cursor state is gcsColWidthChanging.
Otherwise, GridState is set to gsHeaderClicking. The cell is drawn in a "pushed" state when goHeaderPushedLook is included in Options and the grid zone is in HeaderPushZones.
gzFixedCols
GridState is set to gsColSizing when goColSizing has been included in Options and the cursor state is gcsColWidthChanging.
Otherwise, GridState is set to gsColMoving and the coordinates for the most recent drag / move candidate are reset. The cell is drawn in a "pushed" state when goHeaderPushedLook is included in Options and the grid zone is in HeaderPushZones. If goFixedColClick has been included in Options2, the Click method and OnClick event handler are enabled for the control.
gzFixedRows
GridState is set to gsRowMoving when goRowSizing is included in Options and CursorState is gcsRowHeightChanging.
Otherwise, GridState is set to gsRowMoving and the coordinates for the most recent drag / move candidate are reset. The cell is drawn using the "pushed" state when goHeaderPushedLook is included in Options and the grid zone is in HeaderPushZones. If goFixedRowClick has been included in Options2, the Click method and OnClick event handler are enabled for the control.
gzNormal
When the mouse down event is over a button-style cell, it is drawn in the "pushed" state. No additional actions are needed for the button event.
Other cells use the values in Options and CursorState to determine whether the mouse event is for column sizing, selection, or enabling/disabling the cell Editor. GridState is updated to the corresponding value.
Modified in LCL version 5.0 to use Options2 to enable or disable Click / OnClick for mouse down events in fixed columns or rows.
See also
An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
