1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-29 12:59:56 +00:00

tm-open-window set focus to existing window (#7708)

* tm-open-window set focus to existing window

* tm-open-window: update docs
This commit is contained in:
Mario Pietsch 2023-10-18 17:10:04 +02:00 committed by GitHub
parent 326ae61929
commit efaa8dd1e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 6 deletions

View File

@ -40,7 +40,7 @@ exports.startup = function() {
variables = $tw.utils.extend({},paramObject,{currentTiddler: title, "tv-window-id": windowID}); variables = $tw.utils.extend({},paramObject,{currentTiddler: title, "tv-window-id": windowID});
// Open the window // Open the window
var srcWindow, var srcWindow,
srcDocument; srcDocument;
// In case that popup blockers deny opening a new window // In case that popup blockers deny opening a new window
try { try {
srcWindow = window.open("","external-" + windowID,"scrollbars,width=" + width + ",height=" + height + (top ? ",top=" + top : "" ) + (left ? ",left=" + left : "" )), srcWindow = window.open("","external-" + windowID,"scrollbars,width=" + width + ",height=" + height + (top ? ",top=" + top : "" ) + (left ? ",left=" + left : "" )),
@ -52,6 +52,7 @@ exports.startup = function() {
$tw.windows[windowID] = srcWindow; $tw.windows[windowID] = srcWindow;
// Check for reopening the same window // Check for reopening the same window
if(srcWindow.haveInitialisedWindow) { if(srcWindow.haveInitialisedWindow) {
srcWindow.focus();
return; return;
} }
// Initialise the document // Initialise the document

View File

@ -1,6 +1,6 @@
caption: tm-open-window caption: tm-open-window
created: 20160424181447704 created: 20160424181447704
modified: 20220301162140993 modified: 20230831201518773
tags: Messages tags: Messages
title: WidgetMessage: tm-open-window title: WidgetMessage: tm-open-window
type: text/vnd.tiddlywiki type: text/vnd.tiddlywiki
@ -20,10 +20,17 @@ The `tm-open-window` [[message|Messages]] opens a tiddler in a new //browser// w
The `tm-open-window` message is best generated with the ActionSendMessageWidget, which in turn is triggered by a widget such as the ButtonWidget. The message is handled by the core itself. The `tm-open-window` message is best generated with the ActionSendMessageWidget, which in turn is triggered by a widget such as the ButtonWidget. The message is handled by the core itself.
<<.tip """When used with the ActionSendMessageWidget, <<.param 'param'>> becomes <<.param '$param'>> """>> <<.tip """When used with the ActionSendMessageWidget, <<.param 'param'>> becomes <<.param '$param'>>.<br>
<<.tip """Parameters <<.param template>>, <<.param windowTitle>>, <<.param width>>, <<.param height>>, <<.param left>> and <<.param top>> require the ActionSendMessageWidget.""">> Parameters <<.param template>>, <<.param windowTitle>>, <<.param width>>, <<.param height>>, <<.param left>> and <<.param top>> require the ActionSendMessageWidget. """>>
<<.tip """<<.from-version 5.2.2>> To close a window opened with tm-open-window use [[WidgetMessage: tm-close-window]]""">>
<<.tip """<<.from-version 5.2.2>> To open a tiddler in more than one new window, use a unique value for <<.param windowID>>""">> <<.tip """<<.from-version 5.2.2>>
To close a window opened with tm-open-window use [[WidgetMessage: tm-close-window]]<br>
To open a tiddler in more than one new window, use a unique value for <<.param windowID>>
""">>
<<.tip """<<.from-version 5.3.2>>
If the new window is hidden by other windows, clicking the "open" button again will bring it to the foreground and set focus to the new window. This behaviour should be consistent for all browsers now
""">>
<$macrocall $name='wikitext-example-without-html' <$macrocall $name='wikitext-example-without-html'
src=""" src="""