Indigo Rose Software

Professional Software Development Tools

 
+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2008
    Location
    Florida
    Posts
    17

    Tree control with checkbox problem

    I am using AMS 7.5.
    I have a tree control with checkboxes, and I need to code some behavior in the "OnCheck" action based in which node is selected.
    However, I have a problem where if the focus is on one node, and then the checkbox on another node is checked, the action fires on the checkbox but with the node which has focus rather than the node which has the checkbox.
    It is not until after the checkbox is checked that the current node becomes the "selected" node.

    Example:
    Tree control with 5 nodes.
    Focus (selected) is on node 2.
    The user checks the checkbox on node 4, the code in the "OnCheck" action has a "strNode = Tree.GetSelectedNode("Tree_Control")" line in the first line of the script, and the valus of strNode is 2, rather than 4 where the checkbox was.

    Is this a bug, or is there a workaround solution to this problem?

  2. #2
    Join Date
    May 2008
    Location
    The Netherlands
    Posts
    109
    there is a difference between selection and checking so it is certainly a thing for a further release, something like tree.getcheckednode
    but what can you do?
    go through al the nodes with a for loop and cycle through al the nodes tables to find the ones that are checked
    I've also attached an example file
    Code:
    nodearray = {1, 1.1, 2, 2.1, 3, 4, 5} -- here you place all your node indexes make sure you don't make any mistakes because then the whole script doesn't work
    checkedtable = {}
    numberchecked = 0 
    for index, node in nodearray do
    result = Tree.GetNode("Tree1", ""..node);
    	if result.Checked == true then
    	 checkednode = node 
    	numberchecked = numberchecked + 1 
    	checkedtable[numberchecked] = ""..checkednode
    	end
    end	
    
    --if you want to use the first table entry, and the first node
    if checkedtable[1] == 1 then
    --put your script here
    end
    
    --if you want to use the last table entry, and the last node
    last = Table.Count(checkedtable);
    if checkedtable[last] == 5 then
    --put your script here
    end
    
    --if you want to find the second node in the table
    for j,k in checkedtable do 
    if k == 2 then
    --put your script here
    end
    end
    Attached Files

  3. #3
    Join Date
    May 2008
    Location
    The Netherlands
    Posts
    109
    does it work for you?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts