How to upgrade from V1.x to V2?

This is a forum focused on providing support for rTree

Moderators: heatherlaine, robinmiller, kevinmiller, wilstrand

Post Reply
jameshale
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 245
Joined: Thu Sep 04, 2008 6:23 am
Location: Melbourne Australia

How to upgrade from V1.x to V2?

Post by jameshale » Mon Oct 21, 2013 8:37 am

Hi Mats,

I have rTree V1.59 in a current project.
How do I upgrade the rTree engine to V2?
Also, will I need to change commands to ensure it works as in the previous version (before I explore the added capabilities)?

James

jameshale
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 245
Joined: Thu Sep 04, 2008 6:23 am
Location: Melbourne Australia

Re: How to upgrade from V1.x to V2?

Post by jameshale » Mon Feb 03, 2014 2:31 pm

well it s not a straight swap that's for sure.

The following worked for me.

open the stack where your rTree 1 control is located
rename the "rTreeEngine.livecode" to something else, say "rTreeEngineV1.livecode"
open version 2's "rTreeEngine.livecode" stack
drag the rTree group onto you existing stack
locate the version 2 rTreeEngine.livecode and make its parent the same as the parent of the old version 1 engine.
copy the script of your rTree V1 control and paste it into the script of the new rTree (v2) group.
rename the new rTree group to the name of your old rTree control
delete the old rTree control.
reposition the new rTree group as required.

ok, you notice I have been referring to the old rTree object as a control and the new rTree object as a group. Yes he changed the object type. So all your scripts will also need to be adjusted accordingly. This includes your calling script and set up script as well as the script in the group itself. So if your rTree object is called "MyrTree" you will need to do a find replace on all scripts of the form:
control "MyrTree" --> group "MyrTree"

If your tree doesn't display as expected it could be due to the node parameter names you have been using to set things up. Some have changed and some have been omitted. This doesn't matter for any custom parameters you have made but just check you are not relying on a parameter that is no longer in use or who's function has actually changed. Also check if any of your custom names have been defined in the new version. If they have you may get unexpected results.

Anyway after doing the above, my upgrade works fine and I get the benefit of the improvements.

P.S. with the change from a control to a group you might need to check for any commands that do not operate on groups.
I called a "Focus on control ..."
Changing it to "Focus on group..." brought up an error. Seems you can't focus on groups. I found an alternative to what I was trying to do as I am sure you will.

wilstrand
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 114
Joined: Mon Jan 03, 2011 3:02 pm
Contact:

Re: How to upgrade from V1.x to V2?

Post by wilstrand » Wed Feb 05, 2014 2:24 pm

Hi James!

First I want to apologize for not responding to your posts here!
I'm not receiving mail reminders from watched topics in the forums any more.
It is not an excuse as I should have checked the forums now and then even
without the email reminders! Anyhow I have reported this to Heather now.

Thank you very, very much for sharing your upgrade method! This is a
wonderful community! Your description is spot on and the only thing I could
add is that there is an "import" function available in rTree v2 that can be
used to import and convert existing data from a version 1 rTree control into
a version 2. The import function is available from the right click menu -
"Build Tree From -> Older rTree Format". What it does is it converts the
Tree and Node properties of the old rTree control into the new array format
of rTree 2. This can be useful if your tree is not built entirely built by
script, for example if the tree has been built using the right click menus.

With my best regards

Mats
http:www.tapirsoft.on-rev.com
Open Source LiveCode Plugins - rIDE, rGrid, rTree
LiveCode projects

jameshale
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 245
Joined: Thu Sep 04, 2008 6:23 am
Location: Melbourne Australia

Re: How to upgrade from V1.x to V2?

Post by jameshale » Wed Feb 05, 2014 3:06 pm

Thanks for the reply Mats. Unfortunately I build the tree by script.

If you check the user list you will see I have added two more issues.
A big one seeming to be that I can't render the tree if the substack containing it isn't open (it is in memory).

Also it seems my p.s. above was premature.
Although I get my tree to appear, it no longer have the behaviours I originally had:
Open/Close nodes without actually acting on the node (my nodes are positional references in a large text block).
Can no longer set the focus to the tree.
Can no longer navigate the tree using the arrow keys (specifically catching the on raw key message).

It like V2 is a completely new beast, so if you have any thoughts on the above I would appreciate it else I will need to drop back to V1.

James

wilstrand
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 114
Joined: Mon Jan 03, 2011 3:02 pm
Contact:

Re: How to upgrade from V1.x to V2?

Post by wilstrand » Wed Feb 05, 2014 3:46 pm

Hi james!

lets try to take this step by step to see if we can get it to work work you.

First try setting the "tabGroupBehavior" of the rTree group to false (see my answer in your "Raw key events and rTree" post also)
That should get you arrow key navigation up and down through the nodes in the tree.

Make sure your tree has focus. You should be able to do that by script like this:

Code: Select all

focus fld "BackgroundField" of grp "rTree"
Now you should be set up to have the rTree group receive your key events.

Please remember to pass the handler messages from your rTree group script. Else the rTreeEngine will not receive them with unexpected behavior as the result.

About your:
Open/Close nodes without actually acting on the node (my nodes are positional references in a large text block).
I'm not sure if I understand. Would it be possible for you to post the related code for me to have a look at?

Best regards
Mats
http:www.tapirsoft.on-rev.com
Open Source LiveCode Plugins - rIDE, rGrid, rTree
LiveCode projects

jameshale
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 245
Joined: Thu Sep 04, 2008 6:23 am
Location: Melbourne Australia

Re: How to upgrade from V1.x to V2?

Post by jameshale » Thu Feb 06, 2014 1:03 am

sorry for delay in getting back. last post was actually 1 am my time and I preferred sleep :-)
Firstly, the "tabgroupbehaviour" was false so that wasn't it.
However.
setting the focus on the background field worked. I can't understand what i did wrong when i tried it, some syntax error or something.
anyway once the tree had focus my code worked.
Now, my code processes the "rawkeydown" message and I DO NOT pass this on.
I tried commenting out my code to see what the built in behaviour was like.
Unfortunately it didn't do all I wanted. For instance, if I am at a closed node with children I want a right arrow to open the node and show the children.
Also, if I am on a childless node, I want the right arrow key to action the node.
As I think I mentioned, my tree is basically a table of contents for a large body of text. It shows chapter and section headings. Clicking on them displays the corresponding text in a display window but keeps the focus in the tree (until the user clicks elsewhere.)
I have included this part of the code here.

Code: Select all

on rawkeyDown theKey
   put the hilitedNodeIDs of me into theNodeID
   put true into render
      switch theKey
           case 65361 # left
                  if  the children_of_node_ID_[theNodeID] of me >0 then
                        set the expanded_of_node_ID_[theNodeID] of me to false
                  else
                        put the parent_of_node_ID_[theNodeID] of me into ptheNodeID
                        set the hilitedNodeIDs of me to ptheNodeID
                  end if
                 break
            case 65363 # right
         if  the children_of_node_ID_[theNodeID] of me >0 then
            set the expanded_of_node_ID_[theNodeID] of me to true
                  else
            put the ref_of_node_ID_[theNodeID] of me into the_page
            section_display the_page
            focus fld "BackgroundField" of grp "TOCNavigation"
                  end if
                 break
         
            case 65362 # up
                  pass rawkeyDown
                  break
            case 65364 # down
                  pass rawkeyDown
                  break
      case 65293 #return key pressed
         put the ref_of_node_ID_[theNodeID] of me into the_page
         section_display the_page
         focus fld "BackgroundField" of grp "TOCNavigation"
         break
      case 65308
         pass rawkeyDown
         put false into render
         break
      case 65309
         pass rawkeyDown
         put false into render
         break
      end switch
   if render then
         dispatch "render_tree" to me
   end if
end rawkeyDown
I will get back with what I mean by the open/close on nodes as well as my initial render issue re the stack needing to be opened.

jameshale
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 245
Joined: Thu Sep 04, 2008 6:23 am
Location: Melbourne Australia

Re: How to upgrade from V1.x to V2?

Post by jameshale » Thu Feb 06, 2014 1:20 am

RE: Open/Close on nodes issue.
Seems I was thinking ahead, rather than what I actually had. I thought I could click on a "closed" node icon and have the node open without actually selecting the node. Even if I could do this I now realise it would present an inconsistent tree interface and confuse the user.

But I still want the nodes of the tree to be able to be selected WITHOUT changing the page being displayed.
So I now realise I need to not act on the "mouse up" to go to the page. Looks like I will instead act on the "mousedoubleup".

This will allow the use to use the arrow keys or the mouse to dance around the tree and once they are where they want to be they can go to the selected node's text by either: double clicking, hitting the return key, or hitting the right arrow key.

Re: initial drawing of tree.
In V1 I rendered my tree in my substack. The substack was in memory but not open.
In V2 when I try to do this I get thrown an error in the "callibratescrollbar" handler of the rTreebahaviour.
After a bit of playing around it was clear that this error only occurred if the stack was not open.
If I opened the stack and ran the tree population handler, there was no error and all worked according to plan.

Is this a new requirement in V2 (that the stack be open)?

Is there a workaround?

jameshale
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 245
Joined: Thu Sep 04, 2008 6:23 am
Location: Melbourne Australia

Re: How to upgrade from V1.x to V2?

Post by jameshale » Fri Feb 07, 2014 4:54 am

RE: requirement for stack requiring rTree to be open when rendering the tree.
I have a work around for my situation although I am still interested if this open stack requirement is new or a bug.

My workaround is simply to construct my tree when I open the stack and not before.
Now that I can construct my tree using the array method the initial delay is almost imperceptible.
On subsequent openings of the stack I can merely check for the presence of the nodedata to determine if I need to reconstruct the tree.
seems to work

wilstrand
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 114
Joined: Mon Jan 03, 2011 3:02 pm
Contact:

Re: How to upgrade from V1.x to V2?

Post by wilstrand » Sat Feb 08, 2014 11:08 am

Hi James!
RE: requirement for stack requiring rTree to be open when rendering the tree.
I have a work around for my situation although I am still interested if this open stack requirement is new or a bug.
I think the problem is related to the rTree engine having to calculate the height of all nodes to get the scrolling right before render.
It does this by, among other things, setting the htmlText of a temporary field to get the formatted height of each node.

I'm looking into this to see if there is a solution to having the tree rendered before the stack is opened. If I find an easy fix I will let you all know
but until then please remember to have your stacks open before rendering your rTrees.

Kind regards
Mats
http:www.tapirsoft.on-rev.com
Open Source LiveCode Plugins - rIDE, rGrid, rTree
LiveCode projects

Post Reply

Return to “rTree”