lmparppei / Beat

Beat - a simple and elegant screenwriting app for macOS
Other
175 stars 30 forks source link

Bug: Small API thing -- cycling docs with API does not also cycle to corresponding plugin #135

Open ftolsson opened 1 year ago

ftolsson commented 1 year ago

Here's a small window layering issue which I'm quite sure used to be gone but has resurfaced:

In the editor window, using ctrl+Tab to cycle open (tabbed) documents will bring its corresponding plugin window to the front. Good and expected.

Previously, cycling tabs from within FTOutliner with Beat.nextTab() and Beat.previousTab() would do the same — but since some time back, this only cycles the document and not the plugin window (i.e. keeps focus in current plugin).

Related or not: If invoked when plugin is focused (hitting cmd+O etc) Beat dialogs like Open and Save will open behind the plugin window. Also, if crashing Beat when running from xCode, the dead plugin window lingers on top of everything obscuring the xCode controls, almost as if plugin Windows been set to uconditionally float on top?

That's all.

lmparppei commented 1 year ago

I can't reproduce this with a fresh plugin. Are you sure you don't have any code that is related to plugin window focus in FTOutliner?

image image
ftolsson commented 1 year ago

Hm. Not in conjunction with tab-switching... From the top of my mind, would using htmlWindow.focus() at some point make its layering stick? Anyway thanks, I'll have to investigate a bit to seee what else I might be doing differently.

lmparppei commented 1 year ago

From the top of my mind, would using htmlWindow.focus() at some point make its layering stick?

It absolutely could. Plugin window levels are set to normal when the host document isn't the main window anymore, otherwise they are floating windows (always on top), which also causes them to stay on top of Xcode when the app crashes or reaches a breakpoint. When a plugin window receives focus, it should make its host document the main window, but also changes its own level.

If you are focusing the HTML window at the wrong moment while also switching tabs, the window level might go out of sync. Try removing some of the .focus() calls and see how it affects window levels. If in any way.

ftolsson commented 1 year ago

Removed all instacnces of htmlWindow.focus()(one) but that didn't help much.

However -- I also now realize that I described the issue wrong.

When opening several tabs (in my case, five) the topmost plugin (i.e. the one belonging to the last opened tab) will stay on top when cycling -- except for some reason when cycling to tab # 2 which will correctly push its corresponding plugin to the top. For all others, it's the last opened one that floats up. Does that make (more/any/none) sense?

lmparppei commented 7 months ago

I think this is finally fixed in Beat 1.999.1.