Hierarchial ListBoxes -- expanded folder inside a folder? 
Author Message
 Hierarchial ListBoxes -- expanded folder inside a folder?

This seems like such a simple thing, but I can't find a way to do it.  
Let's say I have a hierarchical listbox that looks like this:

- Folder 1
  - Folder 2
      Document 3

...and I click on the "Folder 1" disclosure triangle, thus:

+ Folder 1

...and then I click on the disclosure triangle again.  How do I restore
the listbox back to its original state, with both folders open and
"Document 3" visible in the list (and contained in "Folder 2")?

--



Thu, 15 Apr 2004 15:04:17 GMT  
 Hierarchial ListBoxes -- expanded folder inside a folder?

Quote:

> This seems like such a simple thing, but I can't find a way to do it.  
> Let's say I have a hierarchical listbox that looks like this:

> - Folder 1
>   - Folder 2
>       Document 3

> ...and I click on the "Folder 1" disclosure triangle, thus:

> + Folder 1

> ...and then I click on the disclosure triangle again.  How do I restore
> the listbox back to its original state, with both folders open and
> "Document 3" visible in the list (and contained in "Folder 2")?

You have to provide code to memorise (probably in a property of your
behind-the-scenes data structure) the state of every item's expansion. m.

--

  *** REALbasic: The Definitive Guide! The Second Edition! ***
http://www.amazon.com/exec/obidos/ASIN/0596001770/somethingsbymatt



Fri, 16 Apr 2004 08:57:18 GMT  
 Hierarchial ListBoxes -- expanded folder inside a folder?
In article


Quote:


> > This seems like such a simple thing, but I can't find a way to do it.  
> > Let's say I have a hierarchical listbox that looks like this:

> > - Folder 1
> >   - Folder 2
> >       Document 3

> > ...and I click on the "Folder 1" disclosure triangle, thus:

> > + Folder 1

> > ...and then I click on the disclosure triangle again.  How do I restore
> > the listbox back to its original state, with both folders open and
> > "Document 3" visible in the list (and contained in "Folder 2")?

> You have to provide code to memorise (probably in a property of your
> behind-the-scenes data structure) the state of every item's expansion. m.

That part's done.  The question is how do I get from...

+ Folder 1

...to...

- Folder 1
  - Folder 2
      Document 3

...in one click of the mouse?

--



Fri, 16 Apr 2004 12:27:57 GMT  
 Hierarchial ListBoxes -- expanded folder inside a folder?

Quote:

> That part's done.  The question is how do I get from...

> + Folder 1

> ...to...

> - Folder 1
>   - Folder 2
>       Document 3

> ...in one click of the mouse?

addfolder in the expanded event and than expand this folder in code.

Mfg
Christian

--
Kostenlose MacOS und Win95/98/NT Programme unter

http://www.christians-software.de



Fri, 16 Apr 2004 23:00:00 GMT  
 Hierarchial ListBoxes -- expanded folder inside a folder?

Quote:

> In article




> > > This seems like such a simple thing, but I can't find a way to do it.  
> > > Let's say I have a hierarchical listbox that looks like this:

> > > - Folder 1
> > >   - Folder 2
> > >       Document 3

> > > ...and I click on the "Folder 1" disclosure triangle, thus:

> > > + Folder 1

> > > ...and then I click on the disclosure triangle again.  How do I restore
> > > the listbox back to its original state, with both folders open and
> > > "Document 3" visible in the list (and contained in "Folder 2")?

> > You have to provide code to memorise (probably in a property of your
> > behind-the-scenes data structure) the state of every item's expansion. m.

> That part's done.  The question is how do I get from...

> + Folder 1

> ...to...

> - Folder 1
>   - Folder 2
>       Document 3

> ...in one click of the mouse?

Your Expand code must *consult* the expansion state info that you memorised. m.

--

  *** REALbasic: The Definitive Guide! The Second Edition! ***
http://www.amazon.com/exec/obidos/ASIN/0596001770/somethingsbymatt



Sat, 17 Apr 2004 01:53:10 GMT  
 Hierarchial ListBoxes -- expanded folder inside a folder?


Quote:
> > That part's done.  The question is how do I get from...

> > + Folder 1

> > ...to...

> > - Folder 1
> >   - Folder 2
> >       Document 3

> > ...in one click of the mouse?

> addfolder in the expanded event and than expand this folder in code.

Forgive me if I seem especially dense here, but... when the running
event handler is ExpandRow("Folder 1"), what does my code need to do in
order to make "Document 3" a subitem of "Folder 2"?

This is the code in my ListBox's ExpandRow event:

Sub ExpandRow(Row as integer)
    dim a, bound as integer, expandingCell, childCell as hListBoxCell

    expandingCell = cellsShown(row)
    expandingCell.expanded = true

    bound = expandingCell.uboundChild
    for a = 0 to bound
      childCell = hListBoxCell(expandingCell.child(a))

      if childCell.hasChildren then
        addFolder childCell.title     // this adds "Folder 2" to the list
                                      // as a subitem of "Folder 1"
        if childCell.expanded then
          // ...now what?  Calling AddRow or AddFolder here makes
          // "Document 3" a subitem of "Folder 1"; I need to make it
          // a subitem in "Folder 2".  But how?
        end if

      else
        addRow childCell.title
      end if

      if row = ubound(cellsShown) then
        cellsShown.append childCell
      else
        cellsShown.insert row + 1, childCell
      end if
    next

End Sub

--



Sat, 17 Apr 2004 18:54:05 GMT  
 Hierarchial ListBoxes -- expanded folder inside a folder?

Quote:

> when the running
> event handler is ExpandRow("Folder 1"), what does my code need to do in
> order to make "Document 3" a subitem of "Folder 2"?

> Sub ExpandRow(Row as integer)
>     dim a, bound as integer, expandingCell, childCell as hListBoxCell

>     expandingCell = cellsShown(row)
>     expandingCell.expanded = true

>     bound = expandingCell.uboundChild
>     for a = 0 to bound
>       childCell = hListBoxCell(expandingCell.child(a))

>       if childCell.hasChildren then
>         addFolder childCell.title     // this adds "Folder 2" to the list
>                                       // as a subitem of "Folder 1"
>         if childCell.expanded then
>           // ...now what?  Calling AddRow or AddFolder here makes
>           // "Document 3" a subitem of "Folder 1"; I need to make it
>           // a subitem in "Folder 2".  But how?

You need to *set* childCell's expanded to true. This fires another
ExpandRow event, and in that one you insert *its* subitems. m.

--

  *** REALbasic: The Definitive Guide! The Second Edition! ***
http://www.amazon.com/exec/obidos/ASIN/0596001770/somethingsbymatt



Sat, 17 Apr 2004 21:09:02 GMT  
 Hierarchial ListBoxes -- expanded folder inside a folder?
In article


Quote:


> >         if childCell.expanded then
> >           // ...now what?  Calling AddRow or AddFolder here makes
> >           // "Document 3" a subitem of "Folder 1"; I need to make it
> >           // a subitem in "Folder 2".  But how?

> You need to *set* childCell's expanded to true. This fires another
> ExpandRow event, and in that one you insert *its* subitems. m.

Got it!  The line of code that filled in the blank was:

         if childCell.expanded then
           expanded(lastIndex) = true   // fires ExpandRow("Folder 2")
         end if

I was missing the part where setting the "Folder 2" Row's Expanded
property fires an ExpandRow("Folder 2") event, from which I can then
create "Document 3" as a subitem of "Folder 2".

Thanks to you and Christian for your help (and patience).

--



Sun, 18 Apr 2004 02:29:45 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. creating folders and sub folders

2. How to list files, folders and all their files under the folders

3. Folder in listbox can't be opened

4. Listboxes and Folders

5. listbox: is the row a folder or not?

6. listbox and folders

7. nested folders in ListBox

8. Adding rows to a folder in listbox

9. Add item in folder in listbox

10. ListBoxes and Folder Problems

11. A model of the use of Folders and Sub Folders (or any help!)

12. i would like to write 10 files in one folder and next 10 in second folder and so on.

 

 
Powered by phpBB® Forum Software