Reopen window with tm-open-window message

I seem to recall being able to use a button with tm-open-window a second time to reopen the window again.

  • Anyone know how we could make this happen?
  • tm-close-window works so perhaps I could close then open again but that seems wasteful

Is your problem that the new window gets hidden behind the main window?

See https://tiddlywiki.com/#WidgetMessage%3A%20tm-open-window

If you add a unique “windowID” it should use the same window

It remains behind whe I attempt to use the open widow message the second time, yes.

Yes I did - I mased the window ID on the parm “by default”.

Will revisit tomorrow

I will bump this topic by mentioning why I want this.

  • It is possible to spawn multiple windows from a single tiddlywiki, this is very useful on large or multiple monitors.
  • With recent improvements to tiddlywiki we can now register windows as opened and craft template with a close button to close and de-register that window is open
  • We can even close such windows from the parent wiki

I cannot as yet re-open a window and have it brought to the front

  • It I could do so then we can “find” any open window from the parent wiki and jump to it with a click without using the operating system to find the window.

If I can resolve this gap it would be possible to build a fully featured (sub) window manager into tiddlywiki to manage an unlimited number of windows, not dissimilar to Gimp if you have used that. Such windows can;

  • act as remote controls for the parent wiki
  • Enable new multiscreen layouts
  • Separate tiddlers into their own windows
    • From there you can ctrl-p to print what you see in the widow only.
    • capture/save or export what you see in each window
  • Open settings, search and config tiddlers in their own window
  • provide more screen area and much more.

Even better would be if we could do the same or subset of this with tm-open-external-window then it could become a real windows manager for browser windows.

BASIC Anywhere Machine relies heavily on open windows.

Opened via menu items. If a window gets lost, pressing the menu item brings the window back up again.

Try it: Open BAM, click on the Project Menu, click “View Preprocess Code”. Hide the “Preprocess Code” window behind other windows. Go back to BAM, and click on the menus to show the already open but hidden “Preprocess Code” window.

If what works for me A-1 does not work for you, then there’s either a device or browser difference. I’m using a Chromebook. Well, BAM is a TW5.2.3 instance, so differences could be attributed to TW versions behaving differently.

2 Likes

Thanks @Charlie_Veniot your example has led me to discover the problem is on my computer at least, in FireFox only, it works in Chrome and Edge.

I will research further.

The JS function used is window.open(). May be you find something at: Window: open() method - Web APIs | MDN

Thanks @pmario that is a good reference, and it suggests it should be working in FireFox but there are a few possibilities that could be interfering.

I see also;

Window: focus() method

Makes a request to bring the window to the front. It may fail due to user settings and the window isn’t guaranteed to be frontmost before this method returns.

There seems to be a simple fix for FF. I’ll create an issue at GH and post a PR with a fix soon. Thx for reading through it. I did completely miss the .focus() function.

Edit: [BUG] FireFox: tm-open-window does not focus the window if it already exists · Issue #7707 · Jermolene/TiddlyWiki5 · GitHub

1 Like

The PR preview (not production) can be found at: TiddlyWiki — a non-linear personal web notebook

I did test it with FF and Edge on Windows 11.

Fantastic @pmario

Can you possibly give me the changed tiddler(s) so I can use a “monkey patch?” to develop a window manage while we wait?

  • Or the github link/patch

@pmario I downloaded the versel as a monkey patch wiki.

The changed file can be found at: tm-open-window set focus to existing window by pmario · Pull Request #7708 · Jermolene/TiddlyWiki5 · GitHub

1 Like