diff --git a/packages/iris-grid/src/IrisGrid.tsx b/packages/iris-grid/src/IrisGrid.tsx index 7c9cda3b86..4ec736db2d 100644 --- a/packages/iris-grid/src/IrisGrid.tsx +++ b/packages/iris-grid/src/IrisGrid.tsx @@ -113,7 +113,6 @@ import FilterInputField from './FilterInputField'; import { ClearFilterKeyHandler, CopyKeyHandler, - CopyCursorKeyHandler, ReverseKeyHandler, } from './key-handlers'; import { @@ -529,8 +528,6 @@ export class IrisGrid extends Component { this.handleAdvancedMenuOpened = this.handleAdvancedMenuOpened.bind(this); this.handleGotoRowOpened = this.handleGotoRowOpened.bind(this); this.handleGotoRowClosed = this.handleGotoRowClosed.bind(this); - this.handleShowCopyCursor = this.handleShowCopyCursor.bind(this); - this.handleHideCopyCursor = this.handleHideCopyCursor.bind(this); this.handleAdvancedMenuClosed = this.handleAdvancedMenuClosed.bind(this); this.handleAggregationChange = this.handleAggregationChange.bind(this); this.handleAggregationsChange = this.handleAggregationsChange.bind(this); @@ -707,7 +704,6 @@ export class IrisGrid extends Component { ]; if (canCopy) { keyHandlers.push(new CopyKeyHandler(this)); - keyHandlers.push(new CopyCursorKeyHandler(this)); } const { dh } = model; const mouseHandlers = [ @@ -2791,26 +2787,6 @@ export class IrisGrid extends Component { this.setState({ isGotoShown: false }); } - handleShowCopyCursor(): void { - if (!this.grid) { - return; - } - const { copyCursor } = this.props; - const { cursor } = this.grid.state; - if (cursor !== copyCursor) { - this.isCopying = true; - this.grid.setState({ cursor: copyCursor }); - } - } - - handleHideCopyCursor(): void { - if (!this.grid) { - return; - } - this.isCopying = false; - this.grid.setState({ cursor: null }); - } - handleAdvancedMenuClosed(columnIndex: number): void { const { focusedFilterBarColumn, isFilterBarShown } = this.state; if ( diff --git a/packages/iris-grid/src/key-handlers/CopyCursorKeyHandler.ts b/packages/iris-grid/src/key-handlers/CopyCursorKeyHandler.ts deleted file mode 100644 index ec2c1b2f60..0000000000 --- a/packages/iris-grid/src/key-handlers/CopyCursorKeyHandler.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* eslint class-methods-use-this: "off" */ -import { KeyboardEvent } from 'react'; -import { KeyHandler } from '@deephaven/grid'; -import { ContextActionUtils } from '@deephaven/components'; -import { IrisGrid } from '../IrisGrid'; - -class CopyCursorKeyHandler extends KeyHandler { - private irisGrid: IrisGrid; - - constructor(irisGrid: IrisGrid) { - super(); - - this.irisGrid = irisGrid; - } - - onDown(event: KeyboardEvent): boolean { - if (ContextActionUtils.isModifierKeyDown(event) || event.shiftKey) { - this.irisGrid.handleHideCopyCursor(); - } else if (event.altKey) { - this.irisGrid.handleShowCopyCursor(); - } - return false; - } - - onUp(event: KeyboardEvent): boolean { - if (event.key === 'Alt') { - this.irisGrid.handleHideCopyCursor(); - } - return false; - } -} - -export default CopyCursorKeyHandler; diff --git a/packages/iris-grid/src/key-handlers/index.ts b/packages/iris-grid/src/key-handlers/index.ts index c732760bb7..2ddf3e7624 100644 --- a/packages/iris-grid/src/key-handlers/index.ts +++ b/packages/iris-grid/src/key-handlers/index.ts @@ -1,4 +1,3 @@ export { default as CopyKeyHandler } from './CopyKeyHandler'; -export { default as CopyCursorKeyHandler } from './CopyCursorKeyHandler'; export { default as ReverseKeyHandler } from './ReverseKeyHandler'; export { default as ClearFilterKeyHandler } from './ClearFilterKeyHandler'; diff --git a/packages/iris-grid/src/mousehandlers/IrisGridContextMenuHandler.tsx b/packages/iris-grid/src/mousehandlers/IrisGridContextMenuHandler.tsx index b3b7345437..8762e0c074 100644 --- a/packages/iris-grid/src/mousehandlers/IrisGridContextMenuHandler.tsx +++ b/packages/iris-grid/src/mousehandlers/IrisGridContextMenuHandler.tsx @@ -337,9 +337,7 @@ class IrisGridContextMenuHandler extends GridMouseHandler { actions.push({ title: 'Copy Column Name', group: IrisGridContextMenuHandler.GROUP_COPY, - shortcutText: ContextActionUtils.isMacPlatform() - ? 'Opt+Click' - : 'Alt+Click', + shortcutText: ContextActionUtils.isMacPlatform() ? '⌥Click' : 'Alt+Click', action: () => { copyToClipboard(model.textForColumnHeader(modelIndex) ?? '').catch(e => log.error('Unable to copy header', e) @@ -636,7 +634,7 @@ class IrisGridContextMenuHandler extends GridMouseHandler { title: 'Copy Cell', group: IrisGridContextMenuHandler.GROUP_COPY, shortcutText: ContextActionUtils.isMacPlatform() - ? 'Opt+Click' + ? '⌥Click' : 'Alt+Click', order: 10, action: () => { diff --git a/packages/iris-grid/src/mousehandlers/IrisGridCopyCellMouseHandler.ts b/packages/iris-grid/src/mousehandlers/IrisGridCopyCellMouseHandler.ts index f7768106a8..96b022e58a 100644 --- a/packages/iris-grid/src/mousehandlers/IrisGridCopyCellMouseHandler.ts +++ b/packages/iris-grid/src/mousehandlers/IrisGridCopyCellMouseHandler.ts @@ -39,8 +39,18 @@ class IrisGridCopyCellMouseHandler extends GridMouseHandler { return false; } - onMove(): EventHandlerResult { - if (this.irisGrid.isCopying) { + onMove( + gridPoint: GridPoint, + _grid: Grid, + event: GridMouseEvent + ): EventHandlerResult { + if ( + event.altKey && + !ContextActionUtils.isModifierKeyDown(event) && + !event.shiftKey && + gridPoint.column != null && + (gridPoint.row != null || gridPoint.columnHeaderDepth != null) + ) { this.cursor = this.irisGrid.props.copyCursor; return true; }