diff options
author | ab <abdullah_ahmed@brown.edu> | 2019-02-19 18:17:17 -0500 |
---|---|---|
committer | ab <abdullah_ahmed@brown.edu> | 2019-02-19 18:17:17 -0500 |
commit | 12d20ab1b9b843d816bde445d9b67b3aa6abc6ae (patch) | |
tree | 5d7a92a2c2c9d54effe888fc2ec5f39f9638647b | |
parent | 2886c2859bfc6ad396fc4bab3e90cf18da5442f1 (diff) |
reference created
-rw-r--r-- | src/client/views/DocumentDecorations.tsx | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/client/views/DocumentDecorations.tsx b/src/client/views/DocumentDecorations.tsx index b44e32c52..4f16453df 100644 --- a/src/client/views/DocumentDecorations.tsx +++ b/src/client/views/DocumentDecorations.tsx @@ -13,18 +13,34 @@ export class DocumentDecorations extends React.Component<{}, { value: string }> private _resizer = "" private _isPointerDown = false; @observable private _opacity = 1; + private keyinput: React.RefObject<HTMLInputElement>; constructor(props: Readonly<{}>) { super(props) DocumentDecorations.Instance = this this.state = { value: document.title }; this.handleChange = this.handleChange.bind(this); + this.keyinput = React.createRef(); } handleChange(event: any) { this.setState({ value: event.target.value }); + console.log("Input box has changed") }; + enterPressed(e: any) { + var key = e.keyCode || e.which; + // enter pressed + if (key == 13) { + var text = e.target.value; + if (text[0] == '#') { + console.log("hashtag"); + // TODO: Change field with switch statement + } + e.target.blur(); + } + } + @computed get Bounds(): { x: number, y: number, b: number, r: number } { return SelectionManager.SelectedDocuments().reduce((bounds, element) => { @@ -147,7 +163,7 @@ export class DocumentDecorations extends React.Component<{}, { value: string }> top: bounds.y - 20 - 20, opacity: this.opacity }}> - <input className="title" type="text" name="dynbox" value={this.state.value} onChange={this.handleChange} onPointerDown={this.onPointerDown} /> + <input ref={this.keyinput} className="title" type="text" name="dynbox" value={this.state.value} onChange={this.handleChange} onPointerDown={this.onPointerDown} onKeyPress={this.enterPressed} /> {/* <div className="title" onPointerDown={this.onPointerDown}>{document.title}</div> */} <div id="documentDecorations-topLeftResizer" className="documentDecorations-resizer" onPointerDown={this.onPointerDown} onContextMenu={(e) => e.preventDefault()}></div> <div id="documentDecorations-topResizer" className="documentDecorations-resizer" onPointerDown={this.onPointerDown} onContextMenu={(e) => e.preventDefault()}></div> |