Close / hide the panel in uxp

hi everyone, is there a function that closes / hides the panel in UXP?
in cep I used this function: CSInterface.closeExtension ()

Not at the moment.

We’re evaluating how much programmatic control plugins should have over the workspace given that it’s possible to interrupt the user’s workflow in painful ways. We’re not ruling anything out – but want to figure out the right path forward.

In such a case plugin would get poor ratings and comments so people just would not use it anymore.

And add it as permission into permission settings if you need to.

thanks to you @kerrishotts and @Jarda for your reply,surely there are many ways to disable the panel.
I found this function very useful when checking serial numbers, when the serial was not verified I would close the panel.This is not an issue.i can find other solutions easily. I was wondering if it was still there as it was previously

@svumme Did you find another solution when checking serial numbers, I am interested to hear if you did.

Thanks

@IanBarber
even if I don’t like it as a solution, if the serial is not verified I interrupt the script.

I tried that but it looks a bit ugly to me. Closing the panel if the serial number fails would be more elegant

1 Like

@IanBarber I agree with you

Also I need a way to close or at least hide.

Or an option to invoke this “close” menu function:

Screenshot 2022-04-07 at 10.41.05

It exists now?

Thanks

There is no mechanism in UXP to close a plugin’s panel. (You can show panels in PS prerelease, but not hide them programmatically).

Instead of hiding, render some UI to the user that explains what the issue is, and what they can do to rectify the issue. Otherwise the user may wonder why the plugin isn’t working as expected – which can lead to increased support requirements.

1 Like

Any update on this? It’s really insane that we can’t control even our own panels :confused: At least it would be possible to find a command ID in the menu bar, but that’s nearly impossible, considering multi-language menus…

1 Like

Well you are not allowed to close your own plugin but you are allowed to reset whole workplace and that will close your plugin for sure :clown_face:

const {executeAsModal} = require("photoshop").core;
const {batchPlay} = require("photoshop").action;

async function actionCommands() {
   const result = await batchPlay(
      [
         {
            _obj: "reset",
            _target: [
               {
                  _ref: "workspace",
                  _name: "Essentials"
               }
            ],
            _options: {
               dialogOptions: "dontDisplay"
            }
         }
      ],
      {
      }
   );
}

async function runModalFunction() {
   await executeAsModal(actionCommands, {"commandName": "Action Commands"});
}

await runModalFunction();

1 Like

I guess not just your plugin :smiley:

3 Likes

Common… you spoiled the plot twist! :sweat_smile:

5 Likes

I understand reluctance on control over closing panels while running, but on installation it would be great to have a flag in the manifest to set the initial state to visible or hidden. Showing all the panels after install is confusing for the user and just ugly.

At least I figured out that calling showPanel brings that panel to the front, so I use that to get the main panel at the front of the stack at least (the default order seems random?).

1 Like

Hello,
I was wondering if there are any updates on this. I really liked the option to close the panel from CEP: a usecase for me was a hotkey-callable panel with some functions on it that would auto-close on running the functions: to not clutter PS UI with it.

You can run some menu items to toggle panel visibility. You can use Photoshop API to your own plugins by ID… but that is about it.

I am not sure what Adobe is afraid of. If changing panels visibility sounds scary… why not add new permission into a manifest file?

1 Like

oh of course, I should try the menu items toggling — I’ve used a similar thing with AM. Thanks Jarda!

Hm, however some tests proved that it could more complicated than I thought.
“Insert menu item” in the Actions panel doesn’t add any steps when I try to insert the UXP panel.
The Alchemist also doesn’t seem to catch the event of toggling the panel on/off…
I tried to put the name of my panel into the code I got from toggling visibility of a CEP panel but this didn’t work.

This is the code I was using:

    async function actionCommands() {
        const result = await require("photoshop").action.batchPlay([{"_obj":"select","_target":[{"_name":"UXP Test Panel","_ref":"menuItemClass"}]}], {});
    }
    
    async function runModalFunction() {
        await require("photoshop").core.executeAsModal(actionCommands, {"commandName": "Action Commands"});
    }
    
    await runModalFunction();

if I log the result I’m getting the error:
"My UXP Playground: The object “menu item “UXP Test Panel”” is not currently available."

Am I missing something?

You are not missing anything. This works only for built-in menu items and panels.

For non-built-in menu items you could try command ID but this one will be dynamic and change after every PS restart.