diff options
| author | Bob Zeleznik <zzzman@gmail.com> | 2019-03-26 00:02:30 -0400 |
|---|---|---|
| committer | Bob Zeleznik <zzzman@gmail.com> | 2019-03-26 00:02:30 -0400 |
| commit | 970ecdb7158340cec2ea9e9a381d86afa8a59430 (patch) | |
| tree | 1d9067f92f9342bd52784af8023cf82f9ab32d28 /src/client/views/collections | |
| parent | 2264fb874a09ee01540141986325c76650f32c21 (diff) | |
tried to fix keyboard event issue when editing a text note in an embedded free form collection.
Diffstat (limited to 'src/client/views/collections')
| -rw-r--r-- | src/client/views/collections/PreviewCursor.tsx | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/client/views/collections/PreviewCursor.tsx b/src/client/views/collections/PreviewCursor.tsx index cbf36cf9e..5d621f321 100644 --- a/src/client/views/collections/PreviewCursor.tsx +++ b/src/client/views/collections/PreviewCursor.tsx @@ -37,13 +37,13 @@ export class PreviewCursor extends React.Component<PreviewCursorProps> { @action cleanupInteractions = () => { - document.removeEventListener("keypress", this.onKeyPress, true); + document.removeEventListener("keypress", this.onKeyPress, false); } @action onCursorPlaced = (visible: boolean, downX: number, downY: number): void => { if (visible) { - document.addEventListener("keypress", this.onKeyPress, true); + document.addEventListener("keypress", this.onKeyPress, false); this._lastX = downX; this._lastY = downY; } else @@ -52,8 +52,11 @@ export class PreviewCursor extends React.Component<PreviewCursorProps> { @action onKeyPress = (e: KeyboardEvent) => { + // Mixing events between React and Native is finicky. In FormattedTextBox, we set the + // DASHFormattedTextBoxHandled flag when a text box consumes a key press so that we can ignore + // the keyPress here. //if not these keys, make a textbox if preview cursor is active! - if (!e.ctrlKey && !e.altKey && !e.defaultPrevented) { + if (!e.ctrlKey && !e.altKey && !e.defaultPrevented && !(e as any).DASHFormattedTextBoxHandled) { //make textbox and add it to this collection let [x, y] = this.props.getTransform().transformPoint(this._lastX, this._lastY); let newBox = Documents.TextDocument({ width: 200, height: 100, x: x, y: y, title: "new" }); |
