EasyUI Forum
April 27, 2024, 11:04:48 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: [Solved] tree drag drop + keyboard navigation  (Read 4834 times)
xarn
Newbie
*
Posts: 9


View Profile Email
« on: February 21, 2017, 03:50:40 AM »

Hi,

I successfully added keyboard navigation on a tree using a slight variation of the code snippet found here:
http://www.jeasyui.com/forum/index.php?topic=5167.0

The way you listen to keyboard events on a tree was:

Code:
mytree.attr('tabindex', 1).bind('keydown', function (e) {...});

This worked fine ...until DND was enabled on the tree. Afterwards, the event handler isn't even called. Does anyone know how to do it properly?

I also got exactly the same problem with the datagrid. Without DND key events work fine, once enabled it doesn't trigger anymore. ...it would be really nice if there was a proper way to add key bindings.
« Last Edit: February 22, 2017, 12:22:17 AM by xarn » Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #1 on: February 21, 2017, 07:42:33 PM »

The tree must get focus before getting input from the keyboard. Please try this:
Code:
mytree.attr('tabindex', 1).focus().bind('keydown', function (e) {...});
Logged
xarn
Newbie
*
Posts: 9


View Profile Email
« Reply #2 on: February 22, 2017, 12:21:51 AM »

Thanks Jarry,

the focus did the trick. I had to place it in the onClick of the tree though, since it would get lost once you click elsewhere.


Code:
onClick: function(e) {
$(this).focus();
}
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!