Hi,
I have a problem with keypress handler in DynamicForm in SmartGWT 4.x.
As example I have a form with one TextItem.
TextItem has "onChange" listener to redraw itself (on each change in this example).
It is simplified use case, in our application "onChange" listener invokes TextItem.setIcons() to update actions attached to this item for the first time,
when user starts typing into text input ... formItem.setIcons() finally invokes redraw().
Now, in SGWT 4.0, redraw causes, that all keyboard events are lost in focused text item until redraw is not finished and focus is not set back into input.
So if you press quickly "1" and "2" keys, only "1" is catch by text item and the second keypress is lost. User can see value "1" instead of "12".
In fact it does not work only in IE, in Firefox it is OK (probably because refocus after redraw is not in timer?).
It works correctly in both browsers with SGWT3.x.
I like behavior from older Smartclient, even if
I can understand to current solution ... but it damages our implementation.
Do you think that it is correct, that "formItem.setIcons()" or "redraw()" causes that keypress events are lost for a while in text inputs?
Tested on: SmartClient Version: v9.0p_2014-02-11/LGPL Development Only (built 2014-02-11), browser: IE10 and FF26
This is log from SmartClient console when "1" and "2" keys was pressed quickly while focus is within TextItem input.
You can see, that event "2" was catch only by DynamicForm at 14:42:42.070 instead of TextItem.
It seems, that TextItem is able to catch next keypress events after "focusInItem" is invoked at 14:42:42.092.
14:42:41.846:EventHandler:keyDown event with Canvas target: [VMTextItem ID:isc_VMTextItem_1 name:isc_VMTextItem_0], native target: [INPUTElement]{name:isc_VMTextItem_0}
14:42:41.857:VMTextItem.keydown: 1
14:42:41.870:VMDynamicForm.keyDown: 1
14:42:41.876:EventHandler:Event 'keyDown' bubbled to top
14:42:41.881:EventHandler:keyPress event with Canvas target: [VMTextItem ID:isc_VMTextItem_1 name:isc_VMTextItem_0], native target: [INPUTElement]{name:isc_VMTextItem_0}
14:42:41.886:EventHandler:keyPress not handled natively
14:42:41.890:VMTextItem (isc_VMTextItem_1) ... EVENT:handleKeyPress
14:42:41.897:VMTextItem.keypress: 1
14:42:41.902:VMDynamicForm (isc_VMDynamicForm_0) ... EVENT:handleKeyPress:1
14:42:41.907:EventHandler:Event 'keyPress' bubbled to top
14:42:41.917:VMTextItem (isc_VMTextItem_1) ... EVENT:redrawing
14:42:41.921:VMTextItem (isc_VMTextItem_1) ... EVENT:blurItem
14:42:41.934:VMTextItem (isc_VMTextItem_1) ... EVENT:redrawn
14:42:42.055:EventHandler:keyDown event with Canvas target: [DynamicForm ID:isc_VMDynamicForm_0], native target: [BODYElement]{nodeName:BODY}
14:42:42.061:VMDynamicForm.keyDown: 2
14:42:42.065:EventHandler:Event 'keyDown' bubbled to top
14:42:42.070:EventHandler:keyPress event with Canvas target: [DynamicForm ID:isc_VMDynamicForm_0], native target: [BODYElement]{nodeName:BODY}
14:42:42.074:EventHandler:keyPress not handled natively
14:42:42.078:VMDynamicForm (isc_VMDynamicForm_0) ... EVENT:handleKeyPress:2
14:42:42.082:EventHandler:Event 'keyPress' bubbled to top
14:42:42.092:VMTextItem (isc_VMTextItem_1) ... EVENT:focusInItem
14:42:42.101:EventHandler:keyUp event with Canvas target: [VMTextItem ID:isc_VMTextItem_1 name:isc_VMTextItem_0], native target: [INPUTElement]{name:isc_VMTextItem_0}
14:42:42.105:EventHandler:Event 'keyUp' bubbled to top
14:42:42.109:EventHandler:keyUp event with Canvas target: [VMTextItem ID:isc_VMTextItem_1 name:isc_VMTextItem_0], native target: [INPUTElement]{name:isc_VMTextItem_0}
14:42:42.112:EventHandler:Event 'keyUp' bubbled to top
Sample code:
I have a problem with keypress handler in DynamicForm in SmartGWT 4.x.
As example I have a form with one TextItem.
TextItem has "onChange" listener to redraw itself (on each change in this example).
It is simplified use case, in our application "onChange" listener invokes TextItem.setIcons() to update actions attached to this item for the first time,
when user starts typing into text input ... formItem.setIcons() finally invokes redraw().
Now, in SGWT 4.0, redraw causes, that all keyboard events are lost in focused text item until redraw is not finished and focus is not set back into input.
So if you press quickly "1" and "2" keys, only "1" is catch by text item and the second keypress is lost. User can see value "1" instead of "12".
In fact it does not work only in IE, in Firefox it is OK (probably because refocus after redraw is not in timer?).
It works correctly in both browsers with SGWT3.x.
I like behavior from older Smartclient, even if
I can understand to current solution ... but it damages our implementation.
Do you think that it is correct, that "formItem.setIcons()" or "redraw()" causes that keypress events are lost for a while in text inputs?
Tested on: SmartClient Version: v9.0p_2014-02-11/LGPL Development Only (built 2014-02-11), browser: IE10 and FF26
This is log from SmartClient console when "1" and "2" keys was pressed quickly while focus is within TextItem input.
You can see, that event "2" was catch only by DynamicForm at 14:42:42.070 instead of TextItem.
It seems, that TextItem is able to catch next keypress events after "focusInItem" is invoked at 14:42:42.092.
14:42:41.846:EventHandler:keyDown event with Canvas target: [VMTextItem ID:isc_VMTextItem_1 name:isc_VMTextItem_0], native target: [INPUTElement]{name:isc_VMTextItem_0}
14:42:41.857:VMTextItem.keydown: 1
14:42:41.870:VMDynamicForm.keyDown: 1
14:42:41.876:EventHandler:Event 'keyDown' bubbled to top
14:42:41.881:EventHandler:keyPress event with Canvas target: [VMTextItem ID:isc_VMTextItem_1 name:isc_VMTextItem_0], native target: [INPUTElement]{name:isc_VMTextItem_0}
14:42:41.886:EventHandler:keyPress not handled natively
14:42:41.890:VMTextItem (isc_VMTextItem_1) ... EVENT:handleKeyPress
14:42:41.897:VMTextItem.keypress: 1
14:42:41.902:VMDynamicForm (isc_VMDynamicForm_0) ... EVENT:handleKeyPress:1
14:42:41.907:EventHandler:Event 'keyPress' bubbled to top
14:42:41.917:VMTextItem (isc_VMTextItem_1) ... EVENT:redrawing
14:42:41.921:VMTextItem (isc_VMTextItem_1) ... EVENT:blurItem
14:42:41.934:VMTextItem (isc_VMTextItem_1) ... EVENT:redrawn
14:42:42.055:EventHandler:keyDown event with Canvas target: [DynamicForm ID:isc_VMDynamicForm_0], native target: [BODYElement]{nodeName:BODY}
14:42:42.061:VMDynamicForm.keyDown: 2
14:42:42.065:EventHandler:Event 'keyDown' bubbled to top
14:42:42.070:EventHandler:keyPress event with Canvas target: [DynamicForm ID:isc_VMDynamicForm_0], native target: [BODYElement]{nodeName:BODY}
14:42:42.074:EventHandler:keyPress not handled natively
14:42:42.078:VMDynamicForm (isc_VMDynamicForm_0) ... EVENT:handleKeyPress:2
14:42:42.082:EventHandler:Event 'keyPress' bubbled to top
14:42:42.092:VMTextItem (isc_VMTextItem_1) ... EVENT:focusInItem
14:42:42.101:EventHandler:keyUp event with Canvas target: [VMTextItem ID:isc_VMTextItem_1 name:isc_VMTextItem_0], native target: [INPUTElement]{name:isc_VMTextItem_0}
14:42:42.105:EventHandler:Event 'keyUp' bubbled to top
14:42:42.109:EventHandler:keyUp event with Canvas target: [VMTextItem ID:isc_VMTextItem_1 name:isc_VMTextItem_0], native target: [INPUTElement]{name:isc_VMTextItem_0}
14:42:42.112:EventHandler:Event 'keyUp' bubbled to top
Sample code:
Code:
TextItem tmpT1 = new VMTextItem(); tmpT1.addChangedHandler(new ChangedHandler() { public void onChanged(ChangedEvent event) { markForRedraw(); } }); tmpT1.addKeyPressHandler(new KeyPressHandler() { public void onKeyPress(KeyPressEvent event) { SC.logWarn("VMTextItem.keypress: " +event.getKeyName()); } }); tmpT1.addKeyDownHandler(new com.smartgwt.client.widgets.form.fields.events.KeyDownHandler() { public void onKeyDown(com.smartgwt.client.widgets.form.fields.events.KeyDownEvent event) { SC.logWarn("VMTextItem.keydown: " +event.getKeyName()); } }); final VMDynamicForm tmpF = new VMDynamicForm(); tmpF.setItems(tmpT1); tmpF.addKeyDownHandler(new KeyDownHandler() { public void onKeyDown(KeyDownEvent event) { SC.logWarn("VMDynamicForm.keyDown: " +EventHandler.getKey()); } });
Comment