lil-gui
lil-gui copied to clipboard
Make text in disabled controllers selectable
disable()
can be used, but it greys out the DOM element, and we cannot copy the content of the text boxes. It would be nice to have a controller.readonly(true)
method to make the controller read-only, and be still able to access the text values.
What do you think ?
Hi there—yes, totally reasonable. Ideally we could make disable()
behave how you describe, without having to introduce a new method.
Right now, a controller is "disabled" by applying pointer-events: none
to the whole controller and adding the disabled
attribute to any <input>
elements: https://github.com/georgealways/lil-gui/blob/8d20c29fdf77225c1724cf6122ed6611057e1851/src/Controller.js#L222-L233
To get the behavior you're describing, we could instead apply the readonly
attribute to all native inputs and only apply pointer-events: none
to custom inputs as opposed to the whole controller.
Ideally this should work for the other controller types (number and booleans). For example, I want a check box to be non interactable, but not grey out the checkbox.
I had imagined that this behavior would only apply to text inputs (string or number controllers), so that you could copy and paste out a value. What would be the purpose of the other widgets doing this too?
I had imagined that this behavior would only apply to text inputs (string or number controllers), so that you could copy and paste out a value. What would be the purpose of the other widgets doing this too?
My main issue was the greying out, more than the copy-paste issue.
Greying out the controller gives a wrong impression that something is disabled in the datasource, rather than it being readonly. So my issue is more a styling issue. Maybe some kind of border around the data would be sufficient, instead of disabling the whole controller ?
Ah okay—I think I misunderstood your original intent. If the issue is more about appearance than functionality, then you can use the selector .controller.disabled
to apply your own styles to all disabled controllers.