Hello,
I’m currently working on a custom context menu and I tried to follow the GenericDropdownMenu
class. But, this class is manipulating pseudo states to work properly, which is inaccessible outside of the UnityEngine.UIElements
assembly.
targetElement.pseudoStates |= PseudoStates.Active;
I wonder why its scope is set to internal
and how moving it to public
could impact the UITK context?
- Some pseudo state like focus already have event and other internal state so they can’t be modified directly
- The pseudo state is guaranteed to up to date only when generating the visuals or in the custom style resolved callback. There is no other callback that exist to be notified when the value is changed, and there is no way to be certain changing the value will trigger the visual’s regeneration. So the only reliable way to read the pseudo style is through a customStyle that has the matching pseudo state selector.
That being said, not all pseudo style are driven externally. Checked and Disabled should definitely be modifiable. I would have to review Active : It might need to be set through a protected method in clickable…
We “just” need to expose the proper API/callbacks, make sure any misuses won’t interfere with any built-in control, document when would it be possible to set/read the value, create samples, create tests covering most use cases etc… And we need to do all this before landing a new feature.
It is a matter of prioritization and while it would be convenient, very few use case are blocked by this missing. Feel free to leave a note on the product roadmap:
https://unity.com/roadmap/unity-platform/ui