From e12f79e188c32787b5749eba54183002f270f998 Mon Sep 17 00:00:00 2001 From: bobzel Date: Fri, 10 May 2024 11:58:36 -0400 Subject: fixed clicking on template text when template is not selected to get focus right. fixed treeView preDrop to compute sameTree correctly so that presbox treeview can nest documents hierarchically properly. --- src/client/views/nodes/DocumentView.tsx | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/client/views/nodes/DocumentView.tsx') diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx index ada3de355..3e154aead 100644 --- a/src/client/views/nodes/DocumentView.tsx +++ b/src/client/views/nodes/DocumentView.tsx @@ -343,16 +343,18 @@ export class DocumentViewInternal extends DocComponent 0)) { - stopPropagate = false; // don't stop propagation for field templates -- want the selection to propagate up to the root document of the template + if (this.layoutDoc.onDragStart && !(e.ctrlKey || e.button > 0)) { + stopPropagate = false; } preventDefault = false; } - const sendToBack = e.altKey; - this._singleClickFunc = - // prettier-ignore - clickFunc ?? (() => (sendToBack ? documentView._props.bringToFront?.(this.Document, true) : - this._props.select(e.ctrlKey||e.shiftKey, e.metaKey))); + const sendToBack = e.altKey ? () => documentView._props.bringToFront?.(this.Document, true) : undefined; + const selectFunc = () => { + // selecting a view that is part of a template proxies the selection back to the root of the template + const templateRoot = !(e.ctrlKey || e.button > 0) && this._props.docViewPath?.().reverse().find(dv => !dv._props.TemplateDataDocument); // prettier-ignore + (templateRoot || this._docView)?.select(e.ctrlKey || e.shiftKey, e.metaKey); + }; + this._singleClickFunc = clickFunc ?? sendToBack ?? selectFunc; const waitFordblclick = this._props.waitForDoubleClickToClick?.() ?? this.Document.waitForDoubleClickToClick; if ((clickFunc && waitFordblclick !== 'never') || waitFordblclick === 'always') { this._doubleClickTimeout && clearTimeout(this._doubleClickTimeout); @@ -377,17 +379,15 @@ export class DocumentViewInternal extends DocComponent 0))) { - // click events stop here if the document is active and no modes are overriding it - // if this is part of a template, let the event go up to the template root unless right/ctrl clicking + // click events stop here if the document is active and no modes are overriding it + if (Doc.ActiveTool === InkTool.None || this._props.addDocTab === returnFalse) { if ((this._props.isDocumentActive?.() || this._props.isContentActive?.()) && !SnappingManager.ExploreMode && !this.Document.ignoreClick && e.button === 0 && !Doc.IsInMyOverlay(this.layoutDoc) ) { - e.stopPropagation(); - // don't preventDefault. Goldenlayout, PDF text selection and RTF text selection all need it to go though + e.stopPropagation(); // don't preventDefault. Goldenlayout, PDF text selection and RTF text selection all need it to go though // listen to move events when document content isn't active or document is always draggable if (!this.layoutDoc._lockedPosition && (!this.isContentActive() || BoolCast(this.layoutDoc._dragWhenActive, this._props.dragWhenActive))) { -- cgit v1.2.3-70-g09d2