Is it possible to read if Layers Panel is enabled?

I use this function to hide or undhide the Layers Panel for my plugin workflow:

//If Layers Panel is hidden it shows it, and viceversa.
async function toggleLayersPanel() {
  await runCommandID(1098);
}

async function runCommandID(id) {
  await core.performMenuCommand({ 
    commandID: id, 
    kcanDispatchWhileModal: true, 
    _isCommand: false 
  });
}

However, for a better experience as a developer and bring a better UX to users, I would like to read if the Layers Panel is hidden or not. Is it possible?

Using F7 or the function above toggles the Layers Panel, but I would know if the user has the Layers Panel visible or not.

Thanks!

Get panelList from the app. Find panel by panelId (you’ll need to check what’s the ID you need). Panel has visible and obscured properties

bp([
    {
        "_obj": "get",
        "_target": [
            {"_property": 'panelList'},
            {"_ref": "application", "_enum": "ordinal", "_value": "targetEnum"},
        ],
        "_options": {"dialogOptions": "dontDisplay"}
    }
])[0]['panelList']?.find(p => p.ID === panelId)
1 Like

Thanks Karmalakas, how is this supposed to work? Does the bp function returns anything? I tried to console.log() the result but it returns a pending promise.

const res = await batchPlay([
      {
        "_obj": "get",
        "_target": [
          { "_property": 'panelList' },
          { "_ref": "application", "_enum": "ordinal", "_value": "targetEnum" },
        ],
        "_options": { "dialogOptions": "dontDisplay" }
      }
    ])[0]['panelList']?.find(p => p.ID === panelId)

This gives me an error that ‘panelList’ is unfedined.

If I try to console.log() the next code:

const res = await batchPlay([
      {
        "_obj": "get",
        "_target": [
          { "_property": 'panelList' },
          { "_ref": "application", "_enum": "ordinal", "_value": "targetEnum" },
        ],
        "_options": { "dialogOptions": "dontDisplay" }
      }
    ]

It returns a pending promise. I’m kind of new with promises now in UXP so I don’t get it 100% how it works or how I could get the data from that batchPlay command.

Can you elaborate a little more? I would appreciate it! Seems I don’t get it right enough.

Oops… My bad
Forgot to add BP options

        {
            synchronousExecution: true,
            modalBehavior: "execute"
        }

So it would be:

bp(
  [
    {
      "_obj": "get",
      "_target": [
        {"_property": 'panelList'},
        {"_ref": "application", "_enum": "ordinal", "_value": "targetEnum"},
      ],
      "_options": {"dialogOptions": "dontDisplay"}
    }
  ],
  {
    synchronousExecution: true,
    modalBehavior: "execute"
  }
)[0]['panelList']?.find(p => p.ID === panelId)

synchronousExecution: true here is the key to get result

It’s a bit strange that with await batchPlay() you get a promise, because await should give you a normal result and then you could get panel like this:

res[0]['panelList']?.find(p => p.ID === panelId)
2 Likes

This works now perfect Karmalakas, thank you very much!!

Is there a way that I can make visible or not a specifiic panel with some command like this one? Instead the one I have with the runCommandID() function ?

I don’t know of any. I also use command ID, which IMO must be solved by Adobe. This makes no sense to me

1 Like

There have been some but those are no longer available for 3rd parties. I am not a fan of these restrictions.

You could try this one: https://developer.adobe.com/photoshop/uxp/2022/uxp/reference-js/Modules/uxp/Plugin%20Manager/Plugin/#showpanelpanelid But I don’t know if that support panels that you don’t own.

1 Like

From the description I understand this might actually work if you have in manifest v5 this:

"permissions": {        
    "ipc": {
        "enablePluginCommunication": true   
    }
}

Just not clear if this showPanel() is only for plugins panels or for all :thinking:

1 Like

I tested and can confirm that pluginManager is available only with permission.

2 Likes

@photonic Where did you find correct number for runCommandID?

I would like to hide some other panels