From a006717f7a847c1a230a334fa645b7382aa067d2 Mon Sep 17 00:00:00 2001 From: Bob Zeleznik Date: Wed, 10 Apr 2019 23:44:10 -0400 Subject: switched text proxy to appear on selection, not pointerdown --- src/client/views/nodes/FormattedTextBox.tsx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/client/views/nodes/FormattedTextBox.tsx b/src/client/views/nodes/FormattedTextBox.tsx index 69086df42..17125a298 100644 --- a/src/client/views/nodes/FormattedTextBox.tsx +++ b/src/client/views/nodes/FormattedTextBox.tsx @@ -42,6 +42,7 @@ export class FormattedTextBox extends React.Component { private _editorView: Opt; private _reactionDisposer: Opt; private _inputReactionDisposer: Opt; + private _proxyReactionDisposer: Opt; constructor(props: FieldViewProps) { super(props); @@ -92,6 +93,11 @@ export class FormattedTextBox extends React.Component { this.setupEditor(config); } ); + } else { + this._proxyReactionDisposer = reaction(() => this.props.isSelected(), + () => + this.props.isSelected() && Main.Instance.SetTextDoc(this.props.Document, this._ref.current!, this.props.ScreenToLocalTransform()) + ); } this._reactionDisposer = reaction( @@ -141,6 +147,9 @@ export class FormattedTextBox extends React.Component { if (this._inputReactionDisposer) { this._inputReactionDisposer(); } + if (this._proxyReactionDisposer) { + this._proxyReactionDisposer(); + } } shouldComponentUpdate() { @@ -154,7 +163,7 @@ export class FormattedTextBox extends React.Component { // doc.SetData(fieldKey, e.target.value, RichTextField); } onPointerDown = (e: React.PointerEvent): void => { - if (e.buttons === 1 && this.props.isSelected() && !e.altKey && !e.ctrlKey && !e.metaKey) { + if (e.button === 1 && this.props.isSelected() && !e.altKey && !e.ctrlKey && !e.metaKey) { e.stopPropagation(); } } @@ -162,10 +171,6 @@ export class FormattedTextBox extends React.Component { if (e.buttons === 1 && this.props.isSelected() && !e.altKey) { e.stopPropagation(); } - if (this.props.fieldKey !== KeyStore.Archives) { - e.preventDefault(); - Main.Instance.SetTextDoc(this.props.Document, this._ref.current!, this.props.ScreenToLocalTransform()); - } } onFocused = (e: React.FocusEvent): void => { -- cgit v1.2.3-70-g09d2