Copy link to clipboard
Copied
I have this code and I want to choose the color using the eye dropper, but it doesn't work. What's the problem?
I want to choose the color using the eye dropper when closing the dialogue
// Create the dialog
var dlg = new Window("dialog", "Select Color from Layers");
dlg.size = { width: 200, height: 100 };
// Add a button to the dialog
var selectColorButton = dlg.add("button", undefined, "Select Color");
// Define the button action
selectColorButton.onClick = function () {
// Close the dialog
dlg.close();
// Use a delay to ensure the dialog closes before opening the color picker
// Open the color picker
var pickedColor = app.showColorPicker(); // This allows the eyedropper to work
// Now you can do something with the selected color
if (pickedColor) {
// Process the selected color here
}
};
// Show the dialog
dlg.show();
Copy link to clipboard
Copied
Copy link to clipboard
Copied
@Stephen_A_Marsh
Great but the link I found creates a Solider Color layer
But my problem here is that the eye dropper is not used through Dialog and closing it
Copy link to clipboard
Copied
Yes, it does create a solid colour - but you don't have to do all that:
getColorpickerColor();
/* https://graphicdesign.stackexchange.com/questions/125917/how-can-i-get-an-rgb-color-using-photoshops-color-picker-instead-of-systemss */
function getColorpickerColor() {
if (app.showColorPicker()) {
return app.foregroundColor;
} else {
return false;
}
}
Copy link to clipboard
Copied
@Stephen_A_Marsh
I know that the code is done individually directly, but I use a dialogue that has a set of functions, and among those functions is choosing the color. However, when activating the color picker, the eyedropper tool does not work to select elements from the document, and the reason for this is most likely that the dialogue is active even after it is closed.