EVENT:Expanded

Top  Previous  Next

On a LIST control with T in the FORMAT attribute string, the user has clicked on a tree expansion box.

List boxes with a Tree modifier (T) have a Level field (a LONG) following the tree column. On initial display, if this Level is negative, the branch is contracted. (Note: if the line has no children and a negative level, it will show a [+] when it should not, so do not arbitrarily make every level negative, only do so for parent levels.)

 

As the user clicks the [+] [-] icons the tree is expanded and contracted. This does not change the Level sign but does post "expanded" and "contracted" events. On this event, you can manually update the level sign and save the contracted state of the tree.

 

To determine what row is currently selected, query the PROPLIST:MouseDownRow list box property.

Example:

 

OF EVENT:Expanded

GET(PriorQ, 0 + ?List:PriorQ{PROPLIST:MouseDownRow} ) !Row clicked on [+] sign

!since PROP's are strings and GET is overloaded with (Q,String) you

!must convert to number with 0+proplist:xxx (or other ways)

!CHOICE(?List:PriorQ)) will not work since the record is not

!selected when clicking on the [+]

IF ~ERRORCODE()

 PriorQ:Level=ABS(PriorQ:Level)           !Expanded, so make Level Positive

 PUT(PriorQ)

END

 

OF EVENT:Contracted

 GET(PriorQ, 0 + ?List:PriorQ{PROPLIST:MouseDownRow} ) !Row clicked on [-] sign

 IF ~ERRORCODE()

  PriorQ:Level = -ABS(PriorQ:Level)       !Contracted, make Level Negative

  PUT(PriorQ)

 END

 

You can also expand/contract parents by double clicking on a row. You can tell the difference by examining ?List:PriorQ{PROPLIST:MouseDownZone}=LISTZONE:ExpandBox or alerting the MouseLeft2 keycode.