InputDialog.js 861 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * InputDialog.js
  3. *
  4. * @author realor
  5. */
  6. import { Dialog } from './Dialog.js'
  7. class InputDialog extends Dialog {
  8. constructor(application, title, message, value) {
  9. super(title)
  10. this.application = application
  11. this.setI18N(this.application.i18n)
  12. this.setSize(240, 120)
  13. this.inputElem = this.addTextField('inputName', message, value)
  14. this.inputElem.setAttribute('spellcheck', 'false')
  15. this.acceptButton = this.addButton('accept', 'button.accept', () => this.onAccept(this.inputElem.value))
  16. this.cancelButton = this.addButton('cancel', 'button.cancel', () => this.onCancel())
  17. }
  18. onShow() {
  19. this.inputElem.focus()
  20. }
  21. onAccept() {
  22. this.hide()
  23. }
  24. onCancel() {
  25. this.hide()
  26. }
  27. }
  28. export { InputDialog }