cogentcore / core

A free and open source framework for building powerful, fast, and elegant 2D and 3D apps that run on macOS, Windows, Linux, iOS, Android, and the Web with a single pure Go codebase, allowing you to Code Once, Run Everywhere.
http://cogentcore.org/core
BSD 3-Clause "New" or "Revised" License
1.32k stars 71 forks source link

Consider supporting an easier way for end-users to handle widget part names #840

Closed kkoreilly closed 4 months ago

kkoreilly commented 5 months ago

Describe the feature

For example, if someone wanted to do something specific with the label of a button or the trailing icon of a textfield, currently they would have to guess the names of those parts.

Relevant code

No response

rcoreilly commented 5 months ago

Add constant strings. Eg ButtonLabelName - just the name - add a function to make parts path.

kkoreilly commented 4 months ago

We are not going to implement this, since it would be a significant addition of code and API bloat for an unclear end. Very few people should need to customize the parts of a widget in OnWidgetAdded, and if they do, they can find the name in the code or in the inspector. Furthermore, the names are not really rocket science: the label of a button is "label", the icon is "icon", the indicator is "indicator", etc. Also, there are already helper functions in some places where it would be necessary to get the widget (Button.SetTextUpdate, TextField.LeadingIconButton, etc).