Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Stephen on Jan 18, 2010 05:48
open dhtmlx forum
dhtmlxlayout dhtmlxTree change cursor

How can set the cursor in a tree in a dhtmlxlayout container : myatree = leftLayout.cells("a").attachTree("0");

I have a function whereby I reorder tree nodes (after a node move or delete). Reordering can take seconds and so I want to set the cursor to an hourglass but although I can amend the varaibles below the cursor stays as either a pointer or arrow.

myfunc()
{
var pointer=mytree.style_pointer; // == "pointer"
mytree.style_pointer = "wait"; // I've also tried document.body.style.cursor = "wait";
:
mytree.style_pointer = pointer;
}

Answer posted by Alex (support) on Jan 18, 2010 06:24

There isn't public method to dynamically change tree cursor. Cursor should be set before items are added and can't be changed by style_pointer property.

To change it you can use onMouseIn event handler:

show_wait = false

tree.attachEvent("onMouseIn",function(id){

  tree._idpull[id].span.parentNode.style.cursor = (show_wait?"wait":"pointer");
  return true
  })

Answer posted by Stephen on Jan 18, 2010 07:17
Doesn't seem to work at least in the way I want it to.

1) I added the event and added a global show_wait = false;
2) and  in myfunc() at the start I have
a) show_wait = true;
and at the end of the func
b) show_wait = false;
but the cursor does not change unless I remove this b) show_wait = false;
and even then the cursor only changes to an hourglass after myfunc
appears to have finished ie reordered nodes
 (note myfunc() reordering involves using ajax to rename nodes - files-  on the server)

Answer posted by Alex (support) on Jan 18, 2010 07:59
Please check that show_wait variable is change as you expect. Please provide the sample to recreate the issue if the issue still occurs.
Answer posted by Stephen on Jan 22, 2010 07:09
Problem is due to already in an event handler :
function tOnDrop(sid, tid, bid)
{
show_wait = true;
rename dirs/files on server and in tree
show_wait = false;
}
and so only enters tree.attachEvent("onMouseIn",function(id){}
after tOnDrop() completes

Answer posted on Jan 22, 2010 08:22

onMouseIn event is called only once  - when target item changed. So possibly you need to change cursor directly in the onDrop event handler:

function tOnDrop(sid, tid, bid) 
{
tree._idpull[tid].span.parentNode.style.cursor = "wait";
rename dirs/files on server and in tree
tree._idpull[tid].span.parentNode.style.cursor = "pointer";
}

Answer posted by stephen on Jan 27, 2010 03:26
tree._idpull[tid].span.parentNode.style.cursor = "wait";
Does not do whats required because although I'm moving eg red above green below
tid = apples

apples
1 green
2 red
3 yellow

Firebug breakpoints show
tree._idpull[tid].span.parentNode.style.cursor was set to "pointer" on entry
was changed to "wait" but cursor stayed unchanged in dhtmlxtree
and then at end of function it was changed back to pointer
But I removed the change back and still cursor is a pointer
until function ends then cursor is an hourglass when mouse
is over apples

It would be better to change cursor for the whole dhtmlxLayout

Answer posted by Alex (support) on Jan 28, 2010 03:27
Please use http://support.dhtmlx.com/ to ask questions.