3.2.0

OnKeyPress for ENTER in an Input field not firing?

var itsUsername = new AW.UI.Input;
itsUsername.onKeyEnter = function(event) {alert('Test');};


Never fires for Enter, but for all other keys.

Bug?
Karl Thoroddsen
May 15,
Enter key is used to trigger validation events and got cancelled which is probably a bug. You can use onControlValidating, onControlValidated instead.
Alex (ActiveWidgets)
May 15,
Thanks Alex, I'll give it a try.
Karl Thoroddsen
May 15,
There is a problem with that method. The event handlers are also called when you change the text inside an Input field and click outside of it.

The aim was to emulate a Default button on a web page, for example a "Login" button on a page filled with AW.UI.Input controls.

It would be possible to find out the source of the event if we had access to the Event as we could then check the Button member.
Karl Thoroddsen
May 19,
Ah! Found it.

Check the window.event object inside onControlValidate or onControlValidated.

[CODE]
if (window.event.type == 'keydown')
{
doPressDefaultButton();
}
[/CODE]
Karl Thoroddsen
May 19,

This topic is archived.

See also:


Back to support forum