diff options
author | laurawilsonri <laura_wilson@brown.edu> | 2019-02-23 21:42:21 -0500 |
---|---|---|
committer | laurawilsonri <laura_wilson@brown.edu> | 2019-02-23 21:42:21 -0500 |
commit | c2400538b8ca4b68eb8767c8976531202f2ee748 (patch) | |
tree | cd7034e33e209d253b46d9763b03057ea4c65dad | |
parent | 9cf013c5b64af47d5199ef8168a5af6c29461ed9 (diff) |
everything works except text can't be set for textboxes
-rw-r--r-- | src/client/util/SelectionManager.ts | 6 | ||||
-rw-r--r-- | src/client/views/collections/CollectionFreeFormView.tsx | 22 | ||||
-rw-r--r-- | src/client/views/nodes/CollectionFreeFormDocumentView.tsx | 7 | ||||
-rw-r--r-- | src/client/views/nodes/FormattedTextBox.tsx | 1 |
4 files changed, 26 insertions, 10 deletions
diff --git a/src/client/util/SelectionManager.ts b/src/client/util/SelectionManager.ts index 0759ae110..658bf8f93 100644 --- a/src/client/util/SelectionManager.ts +++ b/src/client/util/SelectionManager.ts @@ -1,5 +1,6 @@ import { CollectionFreeFormDocumentView } from "../views/nodes/CollectionFreeFormDocumentView"; import { observable, action } from "mobx"; +import { CollectionFreeFormView } from "../views/collections/CollectionFreeFormView"; export namespace SelectionManager { class Manager { @@ -8,6 +9,11 @@ export namespace SelectionManager { @action SelectDoc(doc: CollectionFreeFormDocumentView, ctrlPressed: boolean): void { + + //remove preview cursor from collection + if (doc.props.ContainingCollectionView != undefined && doc.props.ContainingCollectionView instanceof CollectionFreeFormView) { + doc.props.ContainingCollectionView.hidePreviewCursor(); + } // if doc is not in SelectedDocuments, add it if (!ctrlPressed) { manager.SelectedDocuments = []; diff --git a/src/client/views/collections/CollectionFreeFormView.tsx b/src/client/views/collections/CollectionFreeFormView.tsx index 8facc8f3c..e1b1db685 100644 --- a/src/client/views/collections/CollectionFreeFormView.tsx +++ b/src/client/views/collections/CollectionFreeFormView.tsx @@ -27,12 +27,11 @@ export class CollectionFreeFormView extends CollectionViewBase { private _lastX: number = 0; private _lastY: number = 0; - @observable private _downX: number = 0; - @observable private _downY: number = 0; //determines whether the blinking cursor for indicating whether a text will be made on key down is visible + @observable private _previewCursorVisible: boolean = false; constructor(props: CollectionViewProps) { @@ -100,10 +99,10 @@ export class CollectionFreeFormView extends CollectionViewBase { this._downX = e.pageX; this._downY = e.pageY; //update downX/downY to update UI (used for preview text cursor) - //this.setState({ - // DownX: e.pageX, - // DownY: e.pageY, - //}) + this.setState({ + DownX: e.pageX, + DownY: e.pageY, + }) } } @@ -129,9 +128,8 @@ export class CollectionFreeFormView extends CollectionViewBase { let currScale: number = this.props.ContainingDocumentView!.ScalingToScreenSpace; let x = this.props.DocumentForCollection.GetNumber(KeyStore.PanX, 0); let y = this.props.DocumentForCollection.GetNumber(KeyStore.PanY, 0); - + this._previewCursorVisible = false; this.SetPan(x + (e.pageX - this._lastX) / currScale, y + (e.pageY - this._lastY) / currScale); - console.log("SET PAN"); } this._lastX = e.pageX; this._lastY = e.pageY; @@ -212,7 +210,7 @@ export class CollectionFreeFormView extends CollectionViewBase { let newBox = Documents.TextDocument({ width: 200, height: 100, x: LocalX, y: LocalY, title: "new" }); //set text to be the typed key and get focus on text box //newBox.SetText(KeyStore.Layout, new TextField(FormattedTextBox.LayoutString())); - newBox.SetText(KeyStore.Data, e.key, true); + //newBox.setText(KeyStore.Data, e.key, true); //newBox.SetData(KeyStore.Data, e.key, RichTextField); //SelectionManager.SelectDoc(newBox, false); this.addDocument(newBox); @@ -258,6 +256,12 @@ export class CollectionFreeFormView extends CollectionViewBase { return this.props.GetTransform().scaled(this.scale).translate(x, y); } + //hides the preview cursor for generating new text boxes - called when other docs are selected/dragged + @action + hidePreviewCursor() { + this._previewCursorVisible = false; + } + render() { const Document: Document = this.props.DocumentForCollection; const value: Document[] = Document.GetList<Document>(this.props.CollectionFieldKey, []); diff --git a/src/client/views/nodes/CollectionFreeFormDocumentView.tsx b/src/client/views/nodes/CollectionFreeFormDocumentView.tsx index a2fbe96d2..565deb145 100644 --- a/src/client/views/nodes/CollectionFreeFormDocumentView.tsx +++ b/src/client/views/nodes/CollectionFreeFormDocumentView.tsx @@ -120,6 +120,7 @@ export class CollectionFreeFormDocumentView extends DocumentView { document.removeEventListener("pointerup", this.onPointerUp) document.addEventListener("pointerup", this.onPointerUp); } + } onPointerMove = (e: PointerEvent): void => { @@ -137,11 +138,17 @@ export class CollectionFreeFormDocumentView extends DocumentView { dragData["xOffset"] = e.x - rect.left; dragData["yOffset"] = e.y - rect.top; DragManager.StartDrag(this._mainCont.current, dragData, { + handlers: { dragComplete: this.dragComplete, }, hideSource: true + }) + //remove preview cursor from collection + if (this.props.ContainingCollectionView != undefined && this.props.ContainingCollectionView instanceof CollectionFreeFormView) { + this.props.ContainingCollectionView.hidePreviewCursor(); + } } } e.stopPropagation(); diff --git a/src/client/views/nodes/FormattedTextBox.tsx b/src/client/views/nodes/FormattedTextBox.tsx index 4bec129e5..887a377b5 100644 --- a/src/client/views/nodes/FormattedTextBox.tsx +++ b/src/client/views/nodes/FormattedTextBox.tsx @@ -71,7 +71,6 @@ export class FormattedTextBox extends React.Component<FieldViewProps> { let state: EditorState; const { doc, fieldKey } = this.props; const config = { - doc: new Node(), schema, plugins: [ history(), |