Menu

#31 tree control class item

Windows
closed
5
2012-08-14
2009-09-15
bugstumbler
No

If I understand the docs right, a treecontrol item owns a 'text' field for identification only . What if the item represents a 'person' and I need fields like name, birthdate, street, zip and so on to qualify that person -> like properties ? What if the user should be able to modify some fields and some not ?
Are there plans to enhance the treecontrol or do other solutions exist ?
Thanks.

Discussion

  • Mark Miesfeld

    Mark Miesfeld - 2009-09-15

    Note: I haven't studied the tree-view control as much as some of the other controls, so I'm not as aware of exactly what the docs say as I am on some of the other ooDialog stuff. With that caveat:

    What the docs call the "text" field for a tree view control item is really the label for the item. It is the label you see when the control displayed.

    Note this also in relationship to your questions. What ooDialog does is give the Rexx programmer access to the Windows controls. I've noticed that quite often people seem to confuse the behavior and capabilities of the underlying Windows controls with something that ooDialog is doing. So, they think that the behavior or capability could be simply changed by changing the ooDialog code. That view is a little skewed. ooDialog can not change the underlying behavior of the control.

    If there is a behavior or capability for the underlying control that ooDialog doesn't have a way to access, then that can be added.

    Back to your question:

    "What if the item represents a 'person' and I need fields like name, birthdate, street, zip and so on to qualify that person -> like properties ? What if the user should be able to modify some fields and some not ?"

    The underlying tree-view control doesn't directly provide that through the label of the item. A typical way to approach what you want would be to connect some event to the tree-view control, say a double-click. When the user double-clicks on an item, your program figures out which item was double-clicked and puts up a dialog with entry fields for the "properties" of that person. You can make some of the entry fields read-only if you want.

    The propdemo.rex sample could get you started on that. In the list-view page, if you double click on an item, an infoDialog is put up saying you selected xxx would you like to do something. You can take that example and translate it to a tree control. Your program would need to keep track of what "properties" went with each tree item. This is definitely doable with the current ooDialog.

    One feature that ooDialog does not have, but I would like to add is this: the tree-view and list-view (and some other controls) have the ability to store a user value with each item in the view. If that ability was added to ooDialog, you would be able to store an object, say a directory object with each item. You do basically the same thing. When the user double clicks on the item, you retrieve the object you stored with that item and do what you want with it.

    "Are there plans to enhance the treecontrol or do other solutions exist ?"

    There are plans to enhance ooDialog. The solution I outlined, would still be the basic way to approach with you want though.

     
  • Mark Miesfeld

    Mark Miesfeld - 2009-09-15

    There is also an example in the samples\winsystem directory called displayWindowTree.rex.

    If you run that program, it first comes up with a list-view control showing all the open windows on your desktop. Select "Top-level Windows" and push the "Show" button.

    What opens up is a tree-view showing all the windows as branches of the tree. When you click on the "+" mark for any window, it expands showing the properties of the window as leafs. You could also use that approach to your "person" item. In that example the tree is not enabled for editing, but you could easily make it editable. Then what you do is when you get the notifiication that the user is about to edit one of the leafs representing a person's property, you decide whether that property is editable. If not editable, you simply refuse to allow the edit.

    The oodtree.rex program in samples\oodialog provides an example of how to allow the user to edit the items in the tree. You just need to put the 2 samples together to get what you want.

     
  • bugstumbler

    bugstumbler - 2009-09-16

    Thank you for your detailed help.
    Unfortunately I have annother problem with oorexx.
    When I execute displayWindowTree.rex. the window pops up with nothing displayed, you can press all buttons but nothing happens, neither quit nor s.th. else close that window. You have to cancel the session.
    Hope I will find.

     
  • bugstumbler

    bugstumbler - 2009-09-16

    no further action required - works now
    thanks again

     
  • Mark Miesfeld

    Mark Miesfeld - 2009-09-16

    Okay, good.

     

Anonymous
Anonymous

Add attachments
Cancel