aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/collectionFreeForm/PreviewCursor.tsx
diff options
context:
space:
mode:
authorBob Zeleznik <zzzman@gmail.com>2019-04-12 21:18:30 -0400
committerBob Zeleznik <zzzman@gmail.com>2019-04-12 21:18:30 -0400
commitdb9ee4f0d710d132e33e48cf6f105fd945941003 (patch)
tree505c1b4ecba7b1b7cce4a77f3e3e55b5933a8e03 /src/client/views/collections/collectionFreeForm/PreviewCursor.tsx
parente3caa89d36c501c16acbc56900546d8a4522584a (diff)
combined preview cursor with marquee. moved preview cursor prompt to its own file.
Diffstat (limited to 'src/client/views/collections/collectionFreeForm/PreviewCursor.tsx')
-rw-r--r--src/client/views/collections/collectionFreeForm/PreviewCursor.tsx85
1 files changed, 0 insertions, 85 deletions
diff --git a/src/client/views/collections/collectionFreeForm/PreviewCursor.tsx b/src/client/views/collections/collectionFreeForm/PreviewCursor.tsx
deleted file mode 100644
index 64da8ecc6..000000000
--- a/src/client/views/collections/collectionFreeForm/PreviewCursor.tsx
+++ /dev/null
@@ -1,85 +0,0 @@
-import { action, observable, trace, computed, reaction } from "mobx";
-import { observer } from "mobx-react";
-import { Document } from "../../../../fields/Document";
-import { Documents } from "../../../documents/Documents";
-import { Transform } from "../../../util/Transform";
-import { CollectionFreeFormView } from "./CollectionFreeFormView";
-import "./PreviewCursor.scss";
-import React = require("react");
-import { Main, PreviewCursorPrompt } from "../../Main";
-
-
-export interface PreviewCursorProps {
- getTransform: () => Transform;
- container: CollectionFreeFormView;
- addLiveTextDocument: (doc: Document) => void;
-}
-
-@observer
-export class PreviewCursor extends React.Component<PreviewCursorProps> {
- @observable _lastX: number = 0;
- @observable _lastY: number = 0;
- @observable public DownX: number = 0;
- @observable public DownY: number = 0;
- _showOnUp: boolean = false;
-
- @action
- cleanupInteractions = () => {
- document.removeEventListener("pointerup", this.onPointerUp, true);
- document.removeEventListener("pointermove", this.onPointerMove, true);
- }
-
- @action
- onPointerDown = (e: React.PointerEvent) => {
- if (e.button === 0 && this.props.container.props.active()) {
- document.removeEventListener("keypress", this.onKeyPress, false);
- this._showOnUp = true;
- this.DownX = e.pageX;
- this.DownY = e.pageY;
- document.addEventListener("pointerup", this.onPointerUp, true);
- document.addEventListener("pointermove", this.onPointerMove, true);
- }
- }
- @action
- onPointerMove = (e: PointerEvent): void => {
- if (Math.abs(this.DownX - e.clientX) > 4 || Math.abs(this.DownY - e.clientY) > 4) {
- this._showOnUp = false;
- PreviewCursorPrompt.Visible = false;
- }
- }
-
- onPointerUp = (e: PointerEvent): void => {
- if (this._showOnUp) {
- PreviewCursorPrompt.Show(this.hideCursor, this.DownX, this.DownY);
- document.addEventListener("keypress", this.onKeyPress, false);
- }
- this.cleanupInteractions();
- }
-
- @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 && !(e as any).DASHFormattedTextBoxHandled) {
- //make textbox and add it to this collection
- let [x, y] = this.props.getTransform().transformPoint(this.DownX, this.DownY);
- let newBox = Documents.TextDocument({ width: 200, height: 100, x: x, y: y, title: "typed text" });
- this.props.addLiveTextDocument(newBox);
- PreviewCursorPrompt.Visible = false;
- e.stopPropagation();
- }
- }
-
- hideCursor = () => {
- document.removeEventListener("keypress", this.onKeyPress, false);
- }
- render() {
- return (
- <div className="previewCursorView" onPointerDown={this.onPointerDown}>
- {this.props.children}
- </div>
- );
- }
-} \ No newline at end of file