EasyUI Forum

General Category => Bug Report => Topic started by: erkin on June 01, 2017, 06:36:28 AM



Title: SwitchButton keyboard events
Post by: erkin on June 01, 2017, 06:36:28 AM
A focused SwitchButton chanche self visual state but dont send onChange event by keyboard(Space button), by mouse button only.


Title: Re: SwitchButton keyboard events
Post by: jarry on June 01, 2017, 03:36:43 PM
You should bind the 'keyup' event and switch the status when pressing the SPACE key. Please try this code:
Code:
var sb = $('#sb');
sb.next().attr('tabindex',1).focus().bind('keyup',function(e){
if (e.keyCode == 32){
if (sb.switchbutton('options').checked){
sb.switchbutton('uncheck');
} else {
sb.switchbutton('check');
}
}
});


Title: Re: SwitchButton keyboard events
Post by: erkin on June 02, 2017, 12:20:33 AM
Hi, this example code work right only if SwitchButton will be focused by mouse click directly.
In this case SwitchButton change visual style instantly and call onChange event.
If SwitchButton will be focused by Tab key (from other controls) SwitchButton change visual style with animation and do NOT call onChage event.