lil-gui icon indicating copy to clipboard operation
lil-gui copied to clipboard

Make text in disabled controllers selectable

Open sguimmara opened this issue 2 years ago • 4 comments

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 ?

sguimmara avatar Sep 02 '22 14:09 sguimmara

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.

georgealways avatar Sep 04 '22 12:09 georgealways

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.

sguimmara avatar Sep 05 '22 09:09 sguimmara

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?

georgealways avatar Sep 05 '22 11:09 georgealways

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.

image

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 ?

sguimmara avatar Sep 05 '22 11:09 sguimmara

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.

georgealways avatar Nov 13 '22 14:11 georgealways