key press event input control

How do i fire an event when a user presses enter in an input control in dhtmlx touch?

This is the input control i am using:

view: ‘toolbar’,
type: ‘MainBar’,
elements: [
{
id: ‘search’,
view: ‘input’,
placeholder:“Zoek contactpersoon”,
type:“text”
}
]

This is the event:

$$(“search”).attachEvent(“onKeyPress”,function(key){
alert(key);
});

No alert so far :cry:

When i change “onKeyPress” to “onItemClick” and change key to id i got a alert!

Anyone?

Regards,

William

Components by default to not provide key events, to change it you need to extend them like

dhx.extend($$("search"), dhx.KeyEvents); $$("search").attachEvent("onKeyPress",function(key){ alert(key); });

extended component will have 2 extra events
onKeyPress
onTimedKeyPress - will fire with delay, useful when you want to start something only when user stops text entering

Thanks Stanislav this works great!!!

I’am developing a ipad web app for our sales representives.

Does anyone know how to close the ipad “on screen keyboard” after pressing enter in a input control?

Does anyone know how prevent the ipad from correcting the inputted text for a certain input control? We are searching by name of a contactperson and the ipad is correcting the text all the time for mis spells.

Regards,

William

Does anyone know how to close the ipad “on screen keyboard”
From my experience - you can call focus of some other input on the page. Not quite sure is there any other way to close the keyboard programmatically.

prevent the ipad from correcting the inputted text
You can try to use
{ view:“text”, type:“search”, …
for such kind of input iPad doesn’t provide corrections

{ view:“text”, type:“search”, …
for such kind of input iPad doesn’t provide corrections

This does not work for any reason.

These attributes in then html input works fine for the ipad:

Normal behaviour
Turn off autocorrect
Turn off autocapitalize
Turn off both

How do i provide the attributes autocorrect & autocapitalize to the dhtmlx touch input control?

Regards,

William

Unfortunately it is not possible in current version, will be added in next ones.

@stanislav

This works fine for now:

$$(“search”).getInput().setAttribute(‘autocorrect’,‘off’);
$$(“search”).getInput().setAttribute(‘autocapitalize’,‘off’);
$$(“search”).getInput().setAttribute(‘autocomplete’,‘off’);

To make the on screen keyboard on the ipad disappear this does not work:

$$(“testlabel”).focus();

I have defined a label with id “testlabel” and focused it after pressing enter, but the keyboard won’t disappear. There is no script error and searching in the database after pressing enter works fine, any idea?

regards,

william

I followed the extend method to listen keypress events, it doesn’t work :frowning:

I saw initialization error:
Uncaught TypeError: Cannot read property ‘Pb’ of undefined
dhx.extendtouchui.js:8
(anonymous function)index.html:322

Can help me please??

Thanks!

Such error can occurs if you are provide non-object as one of parameters of dhx.extend