Configuration of Perspective Tree

hi there,

im wondering about the perspective tree component's multiple selection property. i want to disable that.

and second point is, i want to change fontSize of items.

when i checked the manual, i couldnt found these properties. probably i missed something.

is there anybody has an idea?

thanks in advence.

Add fontSize and adjust the margin under props.appearance.unselectedStyle using the modify style button. It will look something like below. You may need to add it to selectedStyle also

▼ unselectedStyle {3}
    classes :
    fontSize : 22
    margin : 3

There is no configuration property to limit the number of items a user may select, but there are workarounds to implement your own limit.

The important question to ask before you get started is this: when a user attempts to select more than one item, do you want to use the item which was already selected, or do you want to use the most recently clicked item?

Both of these scripts belong in a change script on props.selection (right-click props.selection, then select "Add Change Script").

Using the old selection:

	if currentValue and len(currentValue.value) > 1:
		self.props.selection = previousValue

Use the most recently selected item:

	if currentValue and len(currentValue.value) > 1:
		self.props.selection = [currentValue.value[-1]]

Please note that these execute AFTER the user attempts the multi-selection, so there will be a flicker on the component when the user tries to select multiple items, but the code will then execute and modify the selection depending on your choice. As the user has indeed selected more than one item, any binding against props.selection or script which references that prop will need to account for the scenario where there is more than one selection. This should be pretty easy, because any reference would likely be to an indexed address of props.selection anyway, a la self.props.text = self.getSibling("Tree").props.selection[0].

1 Like

thank you so much for your detailed explanation. it worked.

1 Like