commit 39f42ea620781a97d5e85eb933253053bcdd32dc
parent 4598a18c9b3a210c37b584f3a3a03fc9210806ea
Author: Felicitus <felicitus@felicitus.org>
Date: Sat, 14 Nov 2015 19:07:31 +0100
Properly listen to the enter key, fixes #440
Diffstat:
2 files changed, 29 insertions(+), 29 deletions(-)
diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/CategoryEditor/CategoryEditorForm.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/CategoryEditor/CategoryEditorForm.js
@@ -1,19 +1,23 @@
Ext.define('PartKeepr.CategoryEditorForm', {
- extend: 'Ext.form.Panel',
- layout: 'anchor',
- border: false,
- frame: false,
- bodyStyle: 'background:#DBDBDB;padding: 10px;',
- xtype: "CategoryEditorForm",
- items: [{
- xtype: 'textfield',
- name: 'name',
- anchor: '100%',
- fieldLabel: i18n("Name")
- },{
- xtype: 'textarea',
- name: 'description',
- anchor: '100%',
- fieldLabel: i18n("Description")
- }]
-});-
\ No newline at end of file
+ extend: 'Ext.form.Panel',
+ layout: 'anchor',
+ border: false,
+ frame: false,
+ bodyStyle: 'background:#DBDBDB;padding: 10px;',
+ xtype: "CategoryEditorForm",
+ items: [
+ {
+ xtype: 'textfield',
+ name: 'name',
+ anchor: '100%',
+ enableKeyEvents: true,
+ fieldLabel: i18n("Name")
+ }, {
+ xtype: 'textarea',
+ name: 'description',
+ anchor: '100%',
+ enableKeyEvents: true,
+ fieldLabel: i18n("Description")
+ }
+ ]
+});
diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/CategoryEditor/CategoryEditorWindow.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/CategoryEditor/CategoryEditorWindow.js
@@ -11,14 +11,6 @@ Ext.define('PartKeepr.CategoryEditorWindow', {
],
initComponent: function ()
{
- this.keys = [
- {
- key: Ext.event.Event.ENTER,
- handler: this.onEnter,
- scope: this
- }
- ];
-
this.buttons = [
{
text: i18n("Save"),
@@ -40,11 +32,16 @@ Ext.define('PartKeepr.CategoryEditorWindow', {
this.down("CategoryEditorForm").loadRecord(this.record);
+ this.down("textfield[name=name]").on("keypress", this.onEnter, this);
+ this.down("textfield[name=description]").on("keypress", this.onEnter, this);
+
this.on("show", Ext.bind(this._onShow, this));
},
- onEnter: function ()
+ onEnter: function (field, e)
{
- this.onSave();
+ if (e.getKey() == e.ENTER) {
+ this.onSave();
+ }
},
_onShow: function () {
this.down("CategoryEditorForm").items.first().focus();