diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-05-12 17:42:09 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-05-13 12:48:36 -0300 |
commit | 6ea74c268a12325296a1d2e7fc31b02030ddb8bc (patch) | |
tree | 5da94d93acb64e7ab650d240d6cb23c659ad02ca /ui/Dialog.js | |
parent | e783bcf8522fa68e6b221afd18469c3c265b1bb7 (diff) |
use ESM module syntax & minor cleanups
The biggest change here is moving various element classes under more scope-specific directories, which helps to avoid circular dependencies and is just cleaner to navigate and expand in the future. Otherwise this is a largely uncritical port to ESM module syntax! There are probably a number of changes and other cleanups that remain much needed. Whenever I make changes to tui-lib it's hard to believe it's already been <INSERT COUNTING NUMBER HERE> years since the previous time. First commits are from January 2017, and the code originates a month earlier in KAaRMNoD!
Diffstat (limited to 'ui/Dialog.js')
-rw-r--r-- | ui/Dialog.js | 56 |
1 files changed, 0 insertions, 56 deletions
diff --git a/ui/Dialog.js b/ui/Dialog.js deleted file mode 100644 index 0b77b12..0000000 --- a/ui/Dialog.js +++ /dev/null @@ -1,56 +0,0 @@ -const FocusElement = require('./form/FocusElement') - -const Pane = require('./Pane') - -const telc = require('../util/telchars') - -module.exports = class Dialog extends FocusElement { - // A simple base dialog. - // - // Emits the 'cancelled' event when the cancel key (escape) is pressed, - // which should (probably) be handled by the dialog's creator. - // - // Doesn't do anything when focused by default - this should be overridden - // in subclasses. - // - // Automatically adjusts to fill its parent. Has a pane child (this.pane), - // but the pane isn't adjusted at all (you should change its size and - // likely center it in your subclass). - - constructor() { - super() - - this.pane = new Pane() - this.addChild(this.pane) - } - - fixLayout() { - this.w = this.parent.contentW - this.h = this.parent.contentH - } - - open() { - this.oldSelectedElement = this.root.selectedElement - this.opened() - this.visible = true - this.root.select(this) - this.fixLayout() - } - - close() { - this.closed() - this.visible = false - this.root.select(this.oldSelectedElement) - } - - opened() {} - - closed() {} - - keyPressed(keyBuf) { - if (telc.isCancel(keyBuf)) { - this.emit('cancelled') - return false - } - } -} |