With dhtmlxMessage, is there a way to set the focus on the cancel button?
var m = dhtmlx.message({
title: 'Delete Me',
type: 'confirm',
ok: 'Delete',
cancel: 'Cancel',
text: 'Sure you want to? '',
callback: function(r){ }
});
// set focus to the Cancel button
Maybe there is another approach, here the problem:
I’ve added an onkeydown event in the form so that the enter key will fire whatever button in the form has focus.
When the Delete button in the form is pressed, the dhtmlxMessage opens. Then when the enter key is pressed, both the “Ok” event fires in the dhtmlxMessage and then the form’s onKeyDown event fire.
So I am one of 3 things might work:
cancel the event bubble in the dhtmlxMessage callback
Code of message already attempts to move focus to the popup box and to block the onkeydown handler. So enter key must be processed by the confirm box and blocked automatically.
At this point the dhtmlxMessage callback runs and then the message opens again because the form onKeyDown event is triggered. The onkeydown event in the form captures the enter key and if the type is a button, the button is clicked.
Here’s the code excerpt in the form onkeydown event:
if (ev.keyCode==13 && this.getItemType(id)=='button') {
this.clickButton(id)
keyps.cancelEvent(ev);
return
}
Get a guaranteed answer from DHTMLX technical support team
under the most suitable support plan