diff options
author | yipstanley <stanley_yip@brown.edu> | 2019-01-21 21:42:03 -0500 |
---|---|---|
committer | yipstanley <stanley_yip@brown.edu> | 2019-01-21 21:42:03 -0500 |
commit | 6a04f60ce76fbd8274dd9daf285042f9cab16656 (patch) | |
tree | 51b122980818195d79627ea8265ae7b47a7db3ca /src/Main.tsx | |
parent | b0a8b59b967eae3d5812fd8e54e9f4f7a3fb80fc (diff) |
context menu basics working
Diffstat (limited to 'src/Main.tsx')
-rw-r--r-- | src/Main.tsx | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/Main.tsx b/src/Main.tsx index 0a683c858..cb91c33a3 100644 --- a/src/Main.tsx +++ b/src/Main.tsx @@ -9,7 +9,7 @@ import { FreeFormCanvas } from './views/freeformcanvas/FreeFormCanvas'; import { Key, KeyStore as KS, KeyStore } from './fields/Key'; import { NumberField } from './fields/NumberField'; import { Document } from './fields/Document'; -import { configure, runInAction } from 'mobx'; +import { configure, runInAction, action } from 'mobx'; import { NodeStore } from './stores/NodeStore'; import { Documents } from './documents/Documents'; import { DocumentDecorations } from './DocumentDecorations'; @@ -17,6 +17,7 @@ import { CollectionFreeFormView } from './views/freeformcanvas/CollectionFreeFor import { ListField } from './fields/ListField'; import { DocumentView } from './views/nodes/DocumentView'; import { DocumentViewModel } from './viewmodels/DocumentViewModel'; +import { ContextMenu } from './views/ContextMenu'; configure({ enforceActions: "observed" @@ -26,11 +27,27 @@ const mainNodeCollection = new Array<Document>(); let mainContainer = Documents.CollectionDocument(mainNodeCollection, { x: 0, y: 0, width: window.screen.width, height: window.screen.height }) +let mainContvm = new DocumentViewModel(mainContainer); +mainContvm.IsMainDoc = true; + +window.addEventListener("drop", function(e) { + e.preventDefault(); +}, false) +window.addEventListener("dragover", function(e) { + e.preventDefault(); +}, false) +document.addEventListener("pointerdown", action(function(e: PointerEvent) { + if (!ContextMenu.Instance.intersects(e.pageX, e.pageY)) { + ContextMenu.Instance.clearItems() + } +}), true) + ReactDOM.render(( <div style={{display: "grid", width: "100vw", height: "100vh"}}> <h1>Dash Web</h1> + <DocumentView dvm={mainContvm} parent={undefined} /> <DocumentDecorations /> - <DocumentView dvm={new DocumentViewModel(mainContainer)} /> + <ContextMenu /> </div>), document.getElementById('root')); |