Copy link to clipboard
Copied
Hello people,
I have created a dropdown button with three states changing each when inactive, on hover and active and it is functioning well in a browser, but in Photoshop when active it won't show the activated state, instead it creates a rectangle around the button and also doe not open the menu. I guess there is problem between Javascript code and Photoshop compatibility, but am not so sure. Here is the Javascript code:
//dropdown
function dropdown_one(btn) {
document.getElementById("menu_list").classList.toggle("dcontent");
btn.classList.toggle("button-selected");
}
//condition
window.onclick = function(event) {
if (!event.target.matches('.button')) {
var menu = document.getElementsByClassName("dropdown-content");
var i;
for (i = 0; i < menu.length; i++) {
var open_list = menu[i];
if (open_list.classList.contains('dcontent')) {
open_list.classList.remove('dcontent');
}
}
let selected = document.getElementsByClassName("button-selected");
for (let i = 0, len = selected.length; i < len; i++) {
selected[i].classList.remove("button-selected");
}
}
}
Please if someone can adapt this code to function in Photoshop.
Thank you,
teslaball
P.S. Here is an example on codepen.io to show you exactly how i want to function in Photoshop:
Copy link to clipboard
Copied
Well, have you actually looked at the scripting guides? Your code doesn't really make much sense, since a panel button would for instance not be related to the document but to the application. I'm afraid you have some real reading to do...
Mylenium
Copy link to clipboard
Copied
Can you please help me on this?
Copy link to clipboard
Copied
I actually solved the problem by replacing let with var.
Now I have two problems, the first problem is when clicking on the dropdown button it is framed in an orange rectangle and the second problem is when a menu list is opened, it disappears only when clicked in the area of the extension, but when clicking outside in an area somewhere else in photoshop, it stays open.
Some can do the trick please?
Thanks,
teslaball
Copy link to clipboard
Copied
Moved discussion to the scripting forum