Check which panel has the focus on app start

Started by Carlo Didier, November 25, 2017, 08:36:24 PM

Previous topic - Next topic

Carlo Didier

How can I test which panel ("Media & Folders", or the file window) has the focus when an app is started?

I tried IMatch.getActiveView() but that returns info about the view ("Media & Folders", "Categories", "Timeline", ...) but not if the file window had the focus.

Reason: I want to do different things when the focus is in the file window or when it is in the "Media & Folders" panel when the app is started.
I fear that if there is a way to test where the focus was, it'll probably return the "App Manager" panel as an answer ...

JohnZeman

If you launch an app from the favorites panel (right click and choose New from App) you can choose which app panel the app will open in.  Works great for me as I have some app panels assigned to specific apps only.

Edit:  Oops...  Sorry, I misunderstood what you were asking for..

Mario

#2
You cannot query which panel is active, IMatch offers no endpoint for this.
You can use the focusWindow method provided by the IMatch class to select a specific view or a file window.

Maybe try getAppContext to determine the context in which IMatch is currently operating.
This method is usually used for user support apps and training but it may prove useful for your purpose.
It returns data like CONTEXTID_PANELS_IMPORTEXPORT when the Import & Export panel is active.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Carlo Didier

Hmm, I don't think what I want is possible.

getAppContext() always returns
Quote{
  "id": 253756096,
  "name": "CONTEXTID_PANELS_FILEWNDCONTAINER_APP"
}

I'll use buttons to tell the app which reference to use.

Mario

#4
The context is changed when you click on panels inside IMatch. This changes the context and hence the result of this endpoint.

Use a timer in your app to pull the context (say, once per second) and display the output in your app or the console.
Then click on some IMatch panels / views, wait a second an see how the output changes.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Carlo Didier

Quote from: Mario on November 26, 2017, 12:56:56 PMThe contact is changed when you click on panels inside IMatch. This changes the context and hence the result of this endpoint.
That's what I thought. Logical.

Quote from: Mario on November 26, 2017, 12:56:56 PMUse a timer in your app to pull the context (say, once per second) and display the output in your app or the console.
Then click on some IMatch panels / views, wait a second an see how the output changes.
That's not what I want. I want the app to detect whether I was in file window or the "Media & Folders" panel when I start the app (not after it started).
In one case, the app would then check which files I had selected, in the other case, which folders I had selected and do different things.

Mario

#6
QuoteThat's not what I want. I want the app to detect whether I was in file window or the "Media & Folders" panel when I start the app (not after it started).

No solution then. The last context naturally depend on how you have started your app. App Manager? Favorite clicked? Favorite via keyboard shortcut? App Panel? Import & Export panel?
IMatch does not remember the which windows were clicked last or anything. It does not need that information. A panel may have 50 sub-windows, each sub-window may have sub-windows etc. IMatch manages hundreds of windows at a time, in deep hierarchies. The info about the context is only maintained for the benefit of the context help system, nothing else needs this info.

Probably your best bet is to start your app via a Favorite keyboard shortcut.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Carlo Didier

That's what I thought. And I also tried the keyboard shortcut.

In this case I implemented another solution to distinguish between the two cases, so I bypassed the problem  8)