From 0838b590d78c6861bb6c3d83c93032a606806304 Mon Sep 17 00:00:00 2001 From: bobzel Date: Mon, 6 Jun 2022 13:48:13 -0400 Subject: fixed dragging of audioBox not to trigger clicking of buttons --- src/client/views/nodes/AudioBox.tsx | 84 ++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 42 deletions(-) (limited to 'src') diff --git a/src/client/views/nodes/AudioBox.tsx b/src/client/views/nodes/AudioBox.tsx index 787ad939d..70d730ad1 100644 --- a/src/client/views/nodes/AudioBox.tsx +++ b/src/client/views/nodes/AudioBox.tsx @@ -296,11 +296,10 @@ export class AudioBox extends ViewBoxAnnotatableComponent { - if (e.button === 0 && !e.ctrlKey) { + Record = (e: React.PointerEvent) => { + e.button === 0 && !e.ctrlKey && setupMoveUpEvents(this, e, returnFalse, returnFalse, action(() => { this._recorder ? this.stopRecording() : this.recordAudioAnnotation(); - e.stopPropagation(); - } + }), false); } // for play button @@ -338,27 +337,28 @@ export class AudioBox extends ViewBoxAnnotatableComponent { - const newDoc = CurrentUserUtils.GetNewTextDoc( - "", - NumCast(this.rootDoc.x), - NumCast(this.rootDoc.y) + - NumCast(this.layoutDoc._height) + - 10, - NumCast(this.layoutDoc._width), - 2 * NumCast(this.layoutDoc._height) - ); - Doc.GetProto(newDoc).recordingSource = this.dataDoc; - Doc.GetProto(newDoc).recordingStart = ComputedField.MakeFunction(`self.recordingSource["${this.fieldKey}-recordingStart"]`); - Doc.GetProto(newDoc).mediaState = ComputedField.MakeFunction("self.recordingSource.mediaState"); - const overlayDoc = Doc.UserDoc().myOverlayDocs as Doc; - if (DocListCast(overlayDoc[Doc.LayoutFieldKey(overlayDoc)]).includes(this.rootDoc)) { - newDoc.x = this.rootDoc.x; - newDoc.y = NumCast(this.rootDoc.y) + NumCast(this.rootDoc._height); - Doc.AddDocToList(overlayDoc, undefined, newDoc); - } else { - this.props.addDocument?.(newDoc); - } - e.stopPropagation(); + setupMoveUpEvents(this, e, returnFalse, returnFalse, action(() => { + const newDoc = CurrentUserUtils.GetNewTextDoc( + "", + NumCast(this.rootDoc.x), + NumCast(this.rootDoc.y) + + NumCast(this.layoutDoc._height) + + 10, + NumCast(this.layoutDoc._width), + 2 * NumCast(this.layoutDoc._height) + ); + Doc.GetProto(newDoc).recordingSource = this.dataDoc; + Doc.GetProto(newDoc).recordingStart = ComputedField.MakeFunction(`self.recordingSource["${this.fieldKey}-recordingStart"]`); + Doc.GetProto(newDoc).mediaState = ComputedField.MakeFunction("self.recordingSource.mediaState"); + const overlayDoc = Doc.UserDoc().myOverlayDocs as Doc; + if (DocListCast(overlayDoc[Doc.LayoutFieldKey(overlayDoc)]).includes(this.rootDoc)) { + newDoc.x = this.rootDoc.x; + newDoc.y = NumCast(this.rootDoc.y) + NumCast(this.rootDoc._height); + Doc.AddDocToList(overlayDoc, undefined, newDoc); + } else { + this.props.addDocument?.(newDoc); + } + }), false); } @@ -371,21 +371,21 @@ export class AudioBox extends ViewBoxAnnotatableComponent { - this._pauseStart = new Date().getTime(); - this._paused = true; - this._recorder.pause(); - e.stopPropagation(); + recordPause = (e: React.PointerEvent) => { + setupMoveUpEvents(this, e, returnFalse, returnFalse, action(() => { + this._pauseStart = new Date().getTime(); + this._paused = true; + this._recorder.pause(); + }), false); } // continue the recording - @action - recordPlay = (e: React.MouseEvent) => { - this._pauseEnd = new Date().getTime(); - this._paused = false; - this._recorder.resume(); - e.stopPropagation(); + recordPlay = (e: React.PointerEvent) => { + setupMoveUpEvents(this, e, returnFalse, returnFalse, action(() => { + this._pauseEnd = new Date().getTime(); + this._paused = false; + this._recorder.resume(); + }), false); } @@ -504,19 +504,19 @@ export class AudioBox extends ViewBoxAnnotatableComponent -
+
{[media_state.Recording, media_state.Playing].includes(this.mediaState) ?
e.stopPropagation()}> -
+
-
+
@@ -526,7 +526,7 @@ export class AudioBox extends ViewBoxAnnotatableComponent
: -
+
RECORD
} @@ -653,7 +653,7 @@ export class AudioBox extends ViewBoxAnnotatableComponent {!this.path ? this.recordingControls : this.playbackControls} -- cgit v1.2.3-70-g09d2