This is a migrated thread and some comments may be shown as answers.

[Solved] hitting spacebar in node text boxes selects the root node

1 Answer 125 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Nicholas Cloud
Top achievements
Rank 1
Nicholas Cloud asked on 25 Feb 2010, 08:23 PM
Hi, I have a tree with templated nodes.  Each node contains a few text boxes.  When a text box is selected and the spacebar is hit, the root node is immediately selected (no matter where I am working on the tree), and no space is put into the text box that has focus.  This happens once, when the node I'm working with is first selected, and each time I select a subsequent node to work with it.  I have tried capturing the OnClientKeyPressing event to prevent this, but the event is not even firing the first time I hit the spacebar.  When I hit the spacebar after that, it seems to work fine, and the OnClientKeyPressing event fires.  That is until I click on another node and try to type a space in the text box in that node--then the cycle repeats itself. 

Is there a way to totally disable key selection for the entire tree?

EDIT
I've done some further investigation.  When I edit a node, I am swapping out the innerHTML for an HTML block with text fields.  When that happens, I unselect() the node because I don't want the background to change color, but that leaves no selected nodes in the tree.  If I click any other node *before* I type a space into the textbox, everything works fine.  So I'm guessing the tree needs to have at least one selected node if a keydown event occurs within it, otherwise it will automatically select the root node--is this correct?

1 Answer, 1 is accepted

Sort by
0
Nicholas Cloud
Top achievements
Rank 1
answered on 25 Feb 2010, 09:14 PM
I decided to take a different approach.  Instead of de-selecting the current node to make the bacground appear correct, I simply overrode the default CSS rules:

div[class='rtTop rtSelected'] div.rtIn, 
div[class='rtMid rtSelected'] div.rtIn, 
div[class='rtBot rtSelected'] div.rtIn { 
    colorblack !important; 
    background-colortransparent !important; 
    background-imagenone !important; 
    border-colortransparent !important; 

Thus there is always a "selected" node, even though the background won't change for the one I'm actively working with.



Tags
TreeView
Asked by
Nicholas Cloud
Top achievements
Rank 1
Answers by
Nicholas Cloud
Top achievements
Rank 1
Share this question
or