using jsTreev pre 1 stable and hotkeys plugin.
I have a function that is fired when ‘return’ is pressed. I want get text of the node that was hovered before pressing enter. This code $.jstree._focused().get_selected().text() works ONLY if I click the node with my mouse and then press enter.
How can I get the text without using mouse?
I was thinking that _get_hovered would be nice to have.
when I use only keyboard the class for the node I am going to press enter changes and gets new class jstree-hovered. I thought I can use it somehow but I don’t know how.
You actually almost provided your own solution within your question: as jsTree (ever so nicely) adds the
jstree-hoveredclass to the node that is currently being hovered over, all you need to do is find which node has this class from withing your “return” key event handling code.Working example at http://jsfiddle.net/y7XVp/16/