For the grid control, not only are there several different mouse event types, there are also a few different event classes for those types. The most commonly used event class is wx.grid.GridEvent. The grid event class is a subclass of wx.Command-Event, and provides several methods to get at details of the event, as displayed in table 14.8.
Method |
Description |
AltDown() |
Returns true if the alt key was pressed when the event was triggered. |
ControlDown() |
Returns true if the control key was pressed when the event was triggered. |
GetCol() |
Returns the index of the column of the cell where the event occurred. |
GetPosition() |
Returns a wx.Point representing the logical coordinates in pixels where the event occurred. |
GetRow() |
Returns the index of the row of the cell where the event occurred. |
MetaDown() |
Returns true if the meta key was pressed when the event was triggered. |
Selecting() |
Returns True if the event is a selection and False if the event is a deselection of a cell. |
ShiftDown() |
Returns True if the shift key was pressed when the event was triggered. |
There are several different event types associated with wx.grid.GridEvent. As in table 14.9, the names of the event types evoke the event being processed.
Event Type |
Description |
wx.grid.EVT_GRID_CELL_CHANGE |
Triggered when the user changes the data in a cell via an editor. |
wx.grid.EVT_GRID_CELL_LEFT_CLICK |
Triggered when the user performs a left mouse click in a cell. |
Event Type |
Description |
wx.grid.EVT_GRID_CELL_LEFT_DCLICK |
Triggered when the user performs a left mouse double-click in a cell. |
wx.grid.EVT_GRID_CELL_RIGHT_CUCK |
Triggered when the user performs a right mouse click in a cell. |
wx.grid.EVT_GRID_CELL_RIGHT_DCLICK |
Triggered when the user performs a right mouse double-click in a cell. |
wx.grid.EVT_GRID_EDITOR_HIDDEN |
Triggered when a cell editor is hidden at the end of an edit session. |
wx.grid.EVT_GRID_EDITOR_SHOWN |
Triggered when a cell editor is shown at the beginning of an edit session. |
wx.grid.EVT_GRID_LABEL_LEFT_CLICK |
Triggered when the user performs a left mouse click in the row or column label area. |
wx.grid.EVT_GRID_LABEL_LEFT_DCLICK |
Triggered when the user performs a left mouse double click in the row or column label area. |
wx.grid.EVT_GRID_LABEL_RIGHT_CLICK |
Triggered when the user performs a right mouse click in the row or column label area. |
wx.grid.EVT_GRID_LABEL_RIGHT_DCLICK |
Triggered when the user performs a right mouse double click in the row or column label area. |
wx. gri d. EVT_G RI D_S E L ECT_C ELL |
Triggered when the user moves the focus to a new cell, selecting it. |
There are two event types that have an instance of wx.grid.GridSizeEvent. The event types are wx.grid.EVT_GRID_COL_SIZE, triggered when a column is resized, and wx.grid.EVT_GRID_ROW_SIZE, triggered when a row is resized. The grid size event has five of the same methods as wx.GridEvent—AltDown(), ControlDown(), GetPosition(), MetaDown(), and ShiftDown. The final method of wx.grid.GridSizeEvent is GetRowOrCol() that returns the index of the row or column changed, depending on the event type, of course.
There is one event that has an instance of wx.grid.GridRangeSelectEvent. The event type is wx.grid.EVT_GRID_RANGE_SELECT. It is triggered when the user selects a contiguous rectangle of cells. The event instance has methods to GetBottom-RightCoords(), GetBottomRow(), GetLeftCol(), GetRightCol(), GetTopRight-Coords(), and GetTopRow() of the rectangle selected, with the return value being either an integer index or a (row, col) tuple for the coordinate methods.
Finally, there is one event that has an instance of wx.grid.GridEditorCreated-Event with an event type of EVT_GRID_EDITOR_CREATED. As the name implies, the event is triggered when an editor is created by an edit session. The event instance has GetCol(), GetRow(), and GetControl() methods, which return the column index of the event, row index of the event, and the edit control being used, respectively.
Was this article helpful?
Post a comment