Render.ru

Выделение ноды в свитке treeview при выделении объекта в сцене

astron

Пользователь сайта
Рейтинг
2
#1
Как выбрать ноду(подсветить) в свитке TreeView когда выбран соответствующий объект в сцене
 

igorznag

Мастер
Рейтинг
99
#2
Код:
(--start
fn tvChildOfRootNodes nd selObj tv= 
(
for i=0 to nd.nodes.count-1 do
(
if selObj==nd.nodes.item[i].tag.value then tv.selectedNode=nd.nodes.item[i]
tvChildOfRootNodes nd.nodes.item[i] selObj tv --recursive
)--for i=0 to nd.nodes.count-1 do
)--fn tvChildOfRootNodes nd selObj tv= 
try(destroyDialog treeview_rollout)catch()
rollout treeview_rollout "TreeView Scene Browser"
(
fn initTreeView tv = (tv.Indent= 28)
fn addChildren theNode theChildren tv =
(
for c in theChildren do
(
newNode = theNode.Nodes.add c.name --add to the parent!
if c.isselected then tv.selectedNode=newNode
newNode.tag = dotNetMXSValue c --.tag can contain a MXS value
addChildren newNode c.children tv --recursive call for new node
)--for c in theChildren do
)--fn addChildren theNode theChildren =
fn fillInTreeView tv =
(
theRoot = tv.Nodes.add "WORLD ROOT" --add parent node
tv.selectedNode=theRoot
rootNodes = for o in objects where o.parent == undefined collect o
addChildren theRoot rootNodes tv --no need to pass the TreeView
)
dotNetControl tv "TreeView" width: 190 height:290 align:#center
spinner spn_indent "Indentation" range:[0,100,28] type:#integer fieldwidth:40
on tv Click arg do 
(
hitNode = tv.GetNodeAt (dotNetObject "System.Drawing.Point" arg.x arg.y)
if hitNode != undefined do --if a TreeView node was clicked,
try(select hitNode.tag.value)catch(max select none) 
)
on spn_indent changed val do tv.indent = val
on treeview_rollout open do (initTreeView tv;fillInTreeView tv; tv.HideSelection = false)
); createDialog treeview_rollout 200 320

deleteAllChangeHandlers id:#igorznag_treeview_select_node
when  select objects change id:#igorznag_treeview_select_node handleAt:#redrawViews obj do
try (
    treeview_rollout.tv.selectedNode=treeview_rollout.tv.nodes.item[0]; obj=selection[1]; 
    for i=0 to (treeview_rollout.tv.nodes.count-1) do tvChildOfRootNodes treeview_rollout.tv.nodes.item[i] obj treeview_rollout.tv) catch()
)--end
 
Сверху