Skip to content

Commit

Permalink
On row context menu (#301)
Browse files Browse the repository at this point in the history
* Initial context menu support.
  • Loading branch information
difelice authored and wcjordan committed Mar 3, 2018
1 parent 89fa9ae commit 7af58f1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/FixedDataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,11 @@ var FixedDataTable = createReactClass({
*/
onRowDoubleClick: PropTypes.func,

/**
* Callback that is called when a contextual-menu event happens on a row.
*/
onRowContextMenu: PropTypes.func,

/**
* Callback that is called when a mouse-down event happens on a row.
*/
Expand Down Expand Up @@ -834,6 +839,7 @@ var FixedDataTable = createReactClass({
offsetTop={offsetTop}
onRowClick={state.onRowClick}
onRowDoubleClick={state.onRowDoubleClick}
onRowContextMenu={state.onRowContextMenu}
onRowMouseDown={state.onRowMouseDown}
onRowMouseUp={state.onRowMouseUp}
onRowMouseEnter={state.onRowMouseEnter}
Expand Down
2 changes: 2 additions & 0 deletions src/FixedDataTableBufferedRows.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ var FixedDataTableBufferedRows = createReactClass({
offsetTop: PropTypes.number.isRequired,
onRowClick: PropTypes.func,
onRowDoubleClick: PropTypes.func,
onRowContextMenu: PropTypes.func,
onRowMouseDown: PropTypes.func,
onRowMouseUp: PropTypes.func,
onRowMouseEnter: PropTypes.func,
Expand Down Expand Up @@ -175,6 +176,7 @@ var FixedDataTableBufferedRows = createReactClass({
scrollableColumns={props.scrollableColumns}
onClick={props.onRowClick}
onDoubleClick={props.onRowDoubleClick}
onContextMenu={props.onRowContextMenu}
onMouseDown={props.onRowMouseDown}
onMouseUp={props.onRowMouseUp}
onMouseEnter={props.onRowMouseEnter}
Expand Down
10 changes: 10 additions & 0 deletions src/FixedDataTableRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ class FixedDataTableRowImpl extends React.Component {
*/
onDoubleClick: PropTypes.func,

/**
* Fire when a contextual-menu is requested above a row.
*/
onContextMenu: PropTypes.func,

/**
* Callback for when resizer knob (in FixedDataTableCell) is clicked
* to initialize resizing. Please note this is only on the cells
Expand Down Expand Up @@ -252,6 +257,7 @@ class FixedDataTableRowImpl extends React.Component {
className={joinClasses(className, this.props.className)}
onClick={this.props.onClick ? this._onClick : null}
onDoubleClick={this.props.onDoubleClick ? this._onDoubleClick : null}
onContextMenu={this.props.onContextMenu ? this._onContextMenu : null}
onMouseDown={this.props.onMouseDown ? this._onMouseDown : null}
onMouseUp={this.props.onMouseUp ? this._onMouseUp : null}
onMouseEnter={this.props.onMouseEnter || this.props.onMouseLeave ? this._onMouseEnter : null}
Expand Down Expand Up @@ -360,6 +366,10 @@ class FixedDataTableRowImpl extends React.Component {
this.props.onDoubleClick(event, this.props.index);
};

_onContextMenu = (/*object*/ event) => {
this.props.onContextMenu(event, this.props.index)
};

_onMouseUp = (/*object*/ event) => {
this.props.onMouseUp(event, this.props.index);
};
Expand Down

0 comments on commit 7af58f1

Please sign in to comment.