circuitjs1 icon indicating copy to clipboard operation
circuitjs1 copied to clipboard

Add a color picker instead of a textbox for color selection

Open SEVA77 opened this issue 1 year ago • 3 comments

Hello. I would like to suggest replacing the textbox with the browser color picker in Other Options.... To do this, simply change the type attribute in the textf element:

ei.textf.getElement().setAttribute("type", "color");

This simply replaces the <input type="text"> element with a <input type="color"> element. The <input type="color"> element accepts values ​​in #rrggbb hexadecimal format. For GWT there is no difference between the type="color" and the type="text", so the getText() function in EditOptions.java:

String val = ei.textf.getText();

will return the value of the value attribute.

Here’s how it looks in Chromium and Firefox:

Chromium has its own implementation of color selection:

Firefox seems to be using system libraries. Firefox on Windows:

Firefox on Linux:

I haven’t tested the implementation in Safari but according to the specification this element is supported by all browsers.

I hope that I managed to explain everything clearly with my not very good English.

SEVA77 avatar Nov 08 '24 11:11 SEVA77

This is great, I should have done it this way in the first place. But one advantage to the text boxes is that you can delete the text and it will go back to the original colors. (Someone filed an issue that there was no way to do this. It's not the most intuitive way but it works.). Any interest in adding a button to reset all the colors to the default?

pfalstad avatar Nov 09 '24 06:11 pfalstad

I think users in general may not know about this text box feature. Perhaps two buttons are needed to return default values: separately for colors and separately for other options excluding colors. Just to avoid such moments like “I would like to return default only the colors” and “I would like to return default everything except the colors".

SEVA77 avatar Nov 09 '24 09:11 SEVA77

I'd be happy with just a button to reset the colors, since the other options can be reset more easily, or they get reset by loading a circuit.

pfalstad avatar Nov 09 '24 18:11 pfalstad