EasyUI Forum
March 28, 2024, 08:24:24 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: SwitchButton keyboard events  (Read 5762 times)
erkin
Newbie
*
Posts: 29


View Profile
« 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.
Logged
jarry
Administrator
Hero Member
*****
Posts: 2260


View Profile Email
« Reply #1 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');
}
}
});
Logged
erkin
Newbie
*
Posts: 29


View Profile
« Reply #2 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.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!