Added ability for app to close its window
This commit is contained in:
parent
cc113f15c8
commit
e580ea6214
2 changed files with 8 additions and 3 deletions
|
|
@ -8,7 +8,7 @@ import { HeaderMenu } from "../.common/HeaderMenu.jsx";
|
||||||
* @param {Object} props
|
* @param {Object} props
|
||||||
* @param {VirtualFile} props.file
|
* @param {VirtualFile} props.file
|
||||||
*/
|
*/
|
||||||
export function TextEditor({ file, setTitle }) {
|
export function TextEditor({ file, setTitle, close }) {
|
||||||
const [currentFile, setCurrentFile] = useState(file);
|
const [currentFile, setCurrentFile] = useState(file);
|
||||||
const [content, setContent] = useState(file?.content);
|
const [content, setContent] = useState(file?.content);
|
||||||
const [unsavedChanges, setUnsavedChanges] = useState(false);
|
const [unsavedChanges, setUnsavedChanges] = useState(false);
|
||||||
|
|
@ -62,6 +62,7 @@ export function TextEditor({ file, setTitle }) {
|
||||||
onNew={newText}
|
onNew={newText}
|
||||||
onSave={saveText}
|
onSave={saveText}
|
||||||
onSaveAs={saveTextAs}
|
onSaveAs={saveTextAs}
|
||||||
|
onExit={() => { close(); }}
|
||||||
/>
|
/>
|
||||||
<textarea
|
<textarea
|
||||||
className={styles.View}
|
className={styles.View}
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,10 @@ export function Window({ id, app, size, position, focused = false, onInteract, o
|
||||||
resizeObserver.observe(document.getElementById("root"));
|
resizeObserver.observe(document.getElementById("root"));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const close = () => {
|
||||||
|
windowsManager.close(id);
|
||||||
|
};
|
||||||
|
|
||||||
const classNames = [styles["Window-container"]];
|
const classNames = [styles["Window-container"]];
|
||||||
if (maximized)
|
if (maximized)
|
||||||
classNames.push(styles.Maximized);
|
classNames.push(styles.Maximized);
|
||||||
|
|
@ -83,12 +87,12 @@ export function Window({ id, app, size, position, focused = false, onInteract, o
|
||||||
<button onClick={() => setMaximized(!maximized)}>
|
<button onClick={() => setMaximized(!maximized)}>
|
||||||
<FontAwesomeIcon icon={faSquare}/>
|
<FontAwesomeIcon icon={faSquare}/>
|
||||||
</button>
|
</button>
|
||||||
<button onClick={() => { windowsManager.close(id); }}>
|
<button onClick={close}>
|
||||||
<FontAwesomeIcon icon={faXmark}/>
|
<FontAwesomeIcon icon={faXmark}/>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div className={styles["Window-content"]}>
|
<div className={styles["Window-content"]}>
|
||||||
<app.WindowContent {...options} setTitle={setTitle}/>
|
<app.WindowContent {...options} setTitle={setTitle} close={close}/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Draggable>
|
</Draggable>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue