In vision dropdown if I want to reset the dropdown list, I can just set the SelectValue=-1 by scripting, I can also set the no selection data
I don’t knwo how to realize the same function in the perspective dropdown List
In vision dropdown if I want to reset the dropdown list, I can just set the SelectValue=-1 by scripting, I can also set the no selection data
Set the value to null (which is None in Python). Here the reset button has the code,
self.getSibling("Dropdown").props.value = None
A better solution would be to use sendMessage.
On the button onClick action is
system.perspective.sendMessage("dropdownReset", {}, scope = 'view')
On the dropdown, right-click, Configure Scripts, Message Handlers, Add Handler, set Message Type = 'dropdownReset`, set the Listen Scope to 'View' (same as the sendMessage setting above) and add the following code.
self.props.value = None
.
sendMessage protects you from breaking the functionality if you move any of the components into containers, etc.
I can also set the no selection data.
The "Select..." text is set in props.placeholder.text
.
thanks for your support, but 2 more question,
2 . In vision I can change the dropdown component’s background and forground color, but how to realize this funtion in perspective?
my dropdown list value is string, so your logic not works
My purpose is when the dropdown is reset to default show orange, if select a value show green.
Well… this is not my logic, it’s the one you showed in your screenshot ! I just reproduced exactly what you were doing.
If your goal is to give something a specific color when nothing is selected in your dropdown, you can use pretty much the same expression, just check if props.value
is null, or whatever the default value is. Here I check for null and empty string:
this color works , but how to handle when the props.value is null I need disable the botton function?
Set the enabled property to either true or false.
Exactly the same binding only instead of mapping to a color you map it to a value. false
when you want it disabled and true
when you want it enabled.
you put a red circle around the meta.tooltip.enable
. this disabled the tooltip, not the button
the button is at props.enabled
This property:
@Transistor @victordcq @lrose @pascal.fragnoud thanks for all of your support, I just transfer from vision to perspective, a lot of logic have to change