Problem with Treeview and GetEntry Parent

Discuss GUI programming with the RapaGUI plugin here
Post Reply
User avatar
Redlion
Posts: 99
Joined: Sun Jul 10, 2011 5:05 am
Location: Perth, Western Australia

Problem with Treeview and GetEntry Parent

Post by Redlion »

Hi,

I am trying to get the the parent of the node that is "Active" but I get two levels up.

Here is my simple code to show the issue.

Code: Select all

@REQUIRE "RapaGUI"

moai.CreateApp([[
<?xml version="1.0" encoding="iso-8859-1"?>
<application>
    <window title="Test" id="main" notify="closerequest" width="200">
        <vgroup>
           <treeview id="tree">
               <column/>
                   <node name="Level 1">
                       <node name="Level 2">
                            <node name="Level 3">
                            </node>
                            <node name="Level 4">
                                <node name="Level 5">
                            </node>
                            </node>
                        </node>
                   </node>
                   <node name="Category 1">
                       <node name="Category 2">
                            <node name="Category 3">
                            </node>
                        </node>
                   </node>
           </treeview>  
           <text id="name"></text>
           <hgroup>
              <button id="parent"> Parent </button>
              <button id="quit"> Quit </button>
           </hgroup>
        </vgroup>
     </window>

</application>
]])


Function p_EventFunc(msg) 
    Switch msg.action
        Case "RapaGUI":
            
            Switch msg.attribute
                Case "Pressed":
      
                    Switch msg.id
                        Case "quit"
                            End

                        Case "parent"
                            Local Found, p = moai.DoMethod("tree", "GetEntry", "Active", "Parent")
                            If Found = 1
                                Parent$, B$ ,C$ = unpack(p.items)   
                                moai.Set("name", "Text", unpack(p.items))
                            Else
                                moai.Set("name", "Text", " At Root Level ")
                            Endif

                    EndSwitch
                                       
                Case "CloseRequest"
                     Switch msg.id
                                                                     
                        Case "main"
                            End

                     EndSwitch
                
          EndSwitch
    
     EndSwitch
EndFunction

InstallEventHandler({RapaGUI = p_EventFunc})

Repeat
    WaitEvent
Forever
Have I missunderstood what is ment by Parent?

Does any one know how I can get the next level up, and can correct my code.

Thank
Leo
----------------------------------------------------------------------------------------
Redlion
Sam460 Lite
A4000 A3000 A2000 A1200 A1000 A600 A500 CD32
plouf
Posts: 479
Joined: Sun Feb 04, 2018 11:51 pm
Location: Athens,Greece

Re: Problem with Treeview and GetEntry Parent

Post by plouf »

i try your code,

i select (click and became blue) Level 2, and when i click [Parent] text says Level 1, where level 1 is a level up (parent) to 2
if i select level 1 says top level, which is correct, no level up
if i select level 3 says level 2 which again sound correct for "parent"

if you want to get the one that is blue (selected) have to use "active"/"Active"

Code: Select all

moai.DoMethod("tree", "GetEntry", "Active", "Active")
Christos
User avatar
Redlion
Posts: 99
Joined: Sun Jul 10, 2011 5:05 am
Location: Perth, Western Australia

Re: Problem with Treeview and GetEntry Parent

Post by Redlion »

@ plouf

Thanks for looking at this for me, this has turned into a Bug Report, It works as expected in Windows but not in OS4.

Cheers
Leo
----------------------------------------------------------------------------------------
Redlion
Sam460 Lite
A4000 A3000 A2000 A1200 A1000 A600 A500 CD32
User avatar
airsoftsoftwair
Posts: 5454
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Problem with Treeview and GetEntry Parent

Post by airsoftsoftwair »

Yes, this seems to be related to the other issues in the Treeview widget when using MUI already discussed here. Will be fixed...
Post Reply