New Custom Popup Infield

From ARCHICAD20 it is possible to create a tree view popup by using the UI_CUSTOM_POPUP_INFIELD or the UI_CUSTOM_POPUP_LISTITEM commands, and their variations. These commands provide the possibility to define the values of the popup in the User Interface script.

Therefore the requests and global variables, which usage is restricted in the parameterscript but allowed in the User Interface script, can be used with this command.

The custom popup works with scalar and array parameters as well. The usage of a scalar parameter is recommended in two cases:

  • The required information about the chosen value can be fulfilled by a unique ID. In this case the Store Hidden ID should be set to 1, the Tree Depth should be set to the required depth of the tree view (by the maximum of 3). The unique ID will be stored in the parameter.
  • The custom popup is used for giving the value list of a parameter in the User Interface script instead of the parameterscript. In this case the Store Hidden ID should be set to 0, the Tree Depth will not take effect, so it should be set to 0, otherwise it causes a warning. The chosen value will be stored directly into the parameter. For this solution check the FontName List Handling in UI script post.

If the custom popup is used for creating a tree view and both the groups and the child names are needed to be stored, then the usage of an array parameter is recommended. In this case the Store Hidden ID and the Tree Depth should be set to 0. The depth of the tree view will be calculated automatically from the number of the array columns. Only a single-stage hierarchy can be created with array parameters.

The Grouping Method works on scalar and array parameters as well. If it is set to 1, the items in the popup tree view will appear in the same order as they are given in the command. If it is set to 2, the groups with the same name will be found and displayed only once. The items and groups in the popup list will not be sorted in alphabetical order – the groups will be displayed based on their first appearance.

In the following examples a tree view popup is created on the User Interface, where the selected value is displayed as a text on the Floor Plan. The appearance of the popup list will be based on the following table:

TipsAndTricks_CustomPopup_Ex1

Custom popup with scalar parameter

The displayed text will contain the information about the group which the value belongs in a single string. The values of the displayed text can be the following:

TipsAndTricks_CustomPopup_Ex2

For the custom popup the text which needs to be displayed will be the ID of the tree items. This ID is stored as the value of the “stText” parameter. Each tree item is given by the ID, the group where the value belongs, and its name in the tree view.

! ------------------------------------------------------------------------------
! Input parameters controlled by the user:
! ------------------------------------------------------------------------------
! stText - (String) the displayed text

! ------------------------------------------------------------------------------
! User Interface script
! ------------------------------------------------------------------------------
ui_page 1

ui_outfield "Text To Display:", 10, 24, 100, 15
ui_custom_popup_infield "stText", 
	130, 20, 120, 19, 		! X Position, Y Position, Width, Height
	1, 				! Store Hidden ID
	2,  				! Tree Depth
	1,   				! Grouping Method
	"",   				! Selected Value Description: same as the ID
	"Text1_1", "Group1", "Text1",
	"Text1_2", "Group1", "Text2",
	"Text1_3", "Group1", "Text3",
	"Text2_1", "Group2", "Text1",
	"Text3_1", "Group3", "Text1",
	"Text3_2", "Group3", "Text2"

In the 2D script the chosen value is displayed by the TEXT2 command:

! ------------------------------------------------------------------------------
! 2D script
! ------------------------------------------------------------------------------

text2 0, 0, stText

The scripts above result the following User Interface:
TipsAndTricks_CustomPopup_Ex3

Custom popup with array parameter

In the following example the displayed text contains the group and child name of the chosen value, concatenated with a ” —> ” string:

TipsAndTricks_CustomPopup_Ex4

The array parameter used for the custom popup will be “stTextArray[1][2]”. In the first column the group name of the chosen value, in the second column the child name is stored.

! ------------------------------------------------------------------------------
! Input parameters controlled by the user:
! ------------------------------------------------------------------------------
! stTextArray[1][2] - (String) Array parameter containing the chosen Group and Child

! ------------------------------------------------------------------------------
! User Interface script
! ------------------------------------------------------------------------------
ui_page 1

ui_outfield "Text To Display:", 10, 74, 100, 15
ui_custom_popup_infield{2} "stTextArray", 
	130, 70, 120, 19, 	 	! X Position, Y Position, Width, Height
	0, 			 	! Store Hidden ID
	0,  			 	! Tree Depth
	1,   			 	! Grouping Method
	"",   			 	! Selected Value Description: 
	 		 		! the values of the array columns with separator
	"Group1", "Text1",
	"Group1", "Text2",
	"Group1", "Text3",
	"Group2", "Text1",
	"Group3", "Text1",
	"Group3", "Text2"

In the 2D script the group and child strings of the chosen value are displayed by the TEXT2 command:

! ------------------------------------------------------------------------------
! 2D script
! ------------------------------------------------------------------------------

text2 0, -1, stTextArray[1][1] + " ---> " + stTextArray[1][2]

The scripts above result the following User Interface:
TipsAndTricks_CustomPopup_Ex5

Selected Value Description

With the custom popup command it is possible to customize the description of the selected value on the User Interface. Handling the selected value description in the User Interface script before the custom popup command provides that a required string appears on the infield for each chosen values.

Based on the example of custom popup with array parameter, the custom popup command can be written with a custom selected value description. Before the custom popup command the selected value description is defined similarly to the floor plan appearance of the text:

_stSelected = stTextArray[1][1] + "--->" + stTextArray[1][2]
ui_custom_popup_infield{2} "stTextArray", 
	130, 70, 120, 19, 	! X Position, Y Position, Width, Height
	0, 			! Store Hidden ID
	0,  			! Tree Depth
	1,   			! Grouping Method
	_stSelected,   		! Selected Value Description: the values of the
	 		 	! array columns concatenated with a custom separator
	"Group1", "Text1",
	"Group1", "Text2",
	"Group1", "Text3",
	"Group2", "Text1",
	"Group3", "Text1",
	"Group3", "Text2"

This modification results the following User Interface:
TipsAndTricks_CustomPopup_Ex6