From 2557f463c1cfe2d0dd8ea187c184755bd141dab4 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 22 Mar 2012 10:38:44 -0700 Subject: IKNINJA-1302 : For File>New and File>SaveAll dialogs, 'ESC' key now triggers Cancel button and 'Enter' key now triggers OK button. For File picker, the 'ESC' now triggers the Cancel button. Signed-off-by: Ananya Sen Conflicts: js/io/ui/new-file-dialog/new-file-workflow-controller.js Signed-off-by: Ananya Sen --- js/mediators/keyboard-mediator.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'js/mediators') diff --git a/js/mediators/keyboard-mediator.js b/js/mediators/keyboard-mediator.js index 65dd34cd..63dcfa88 100755 --- a/js/mediators/keyboard-mediator.js +++ b/js/mediators/keyboard-mediator.js @@ -246,6 +246,35 @@ exports.KeyboardMediator = Montage.create(Component, { return; } + // check for ENTER key + if((evt.keyCode == Keyboard.ENTER) && !(evt.ctrlKey || evt.metaKey)) { + //new file + if((this.application.ninja.newFileController.newFileOptionsNav !== null) + && !this.application.ninja.newFileController.newFileOptionsNav.okButton.hasAttribute("disabled")){ + + this.application.ninja.newFileController.newFileOptionsNav.handleOkButtonAction(); + } + //save as + if((this.application.ninja.newFileController.saveAsDialog !== null) + && !this.application.ninja.newFileController.saveAsDialog.okButton.hasAttribute("disabled")){ + + this.application.ninja.newFileController.saveAsDialog.handleOkButtonAction(); + } + return; + } + //ESC key + if(evt.keyCode === Keyboard.ESCAPE){ + if(this.application.ninja.filePickerController.pickerNavChoices !== null){ + this.application.ninja.filePickerController.pickerNavChoices.handleCancelButtonAction(); + } + if(this.application.ninja.newFileController.newFileOptionsNav !== null){ + this.application.ninja.newFileController.newFileOptionsNav.handleCancelButtonAction(); + } + if(this.application.ninja.newFileController.saveAsDialog !== null){ + this.application.ninja.newFileController.saveAsDialog.handleCancelButtonAction(); + } + return; + } } }, -- cgit v1.2.3