[TW5] enable cancelling popups in tc-single-tiddler-window

82 views
Skip to first unread message

Simon Huber

unread,
Feb 21, 2018, 6:13:08 AM2/21/18
to TiddlyWikiDev
Hi all,

Is there a way to cancel popups or dropdowns created in a single-tiddler window by clicking in that window, not in the root window?

As you can see here right now tw doesn't handle that: http://rocketdock.tiddlyspot.com
you can click the rocket to open a new window and try the search field for a dropdown

Simon

Andreas Hahn

unread,
Feb 21, 2018, 7:26:38 AM2/21/18
to tiddly...@googlegroups.com
Hi Simon,

unfortunately this is a shortcoming of the current PopupMechanism in
TiddlyWiki and will require changes to the core. The only way to open
and close the popup seems to be with a button.

If you happen to know javascript you could in theory write a
plugin/widget to fix this by adding $tw.popup as an event listener to
the window root dom element. Alternatively I imagine this would be fixed
by having $tw.popup.show register the event listener on the ownerElement
or on all open windows.

/Andreas

Simon Huber

unread,
Feb 21, 2018, 7:34:39 AM2/21/18
to TiddlyWikiDev
Hi, Andreas

I tried hacking a bit in popup.js to see if I can register it to something different but my js knowledge is limited,
I don't know what to use. Right now it does
this.rootElement = options.rootElement || document.documentElement;
on top of popup.js
I think this must be where it can be changed

what I'm looking for is an appropriate way for the core to handle it so that I could try making a pr

thanks for your reply,
Simon

Andreas Hahn

unread,
Feb 21, 2018, 7:49:54 AM2/21/18
to tiddly...@googlegroups.com

Hi Simon,

that is almost the right place yes, if you have a look at core/modules/startup/startup.js [1], you will see that it initializes it without the rootElement being given anyway. The next problem is that all widgets regardless of the window they are rendered in will use $tw.popup.triggerPopup(), so we can't have multiple popup handler (i.e. one per window). The actual event listener however will be registered in $tw.popup.show().

As it stands I see two ways you could make the core properly handle this:

  • Turn the global window variable in core/modules/startup/window.js into $tw.openWindows and make sure that all open windows including the main one are listed there and then have the Popup mechanism iterate through these and register itself (to all of them).
  • Have the Popup mechanism use [2] to register itself to the appropriate window by default and only change this if the rootElement option was set. (Not sure how well this would work in other browsers, but it would require the least change)

[1] https://github.com/Jermolene/TiddlyWiki5/blob/master/core/modules/startup/startup.js#L118

[2] https://developer.mozilla.org/en-US/docs/Web/API/Node/ownerDocument

Simon Huber

unread,
Feb 21, 2018, 8:50:22 AM2/21/18
to TiddlyWikiDev
thanks a lot Andreas,

I've now been trying .../startup/windows.js , which handles the tm-open-window message
couldn't I also try to register it from within there, when the window gets opened?

I'll take a look at your tips, the second seems more appropriate to me, changing that much like in (1) is a bit out of my skill-scope and I guess it would need to change many other things, too

Simon Huber

unread,
Feb 21, 2018, 2:07:05 PM2/21/18
to TiddlyWikiDev
No - I'm not having success. Here I depend on help from above

Jeremy Ruston

unread,
Feb 21, 2018, 4:07:37 PM2/21/18
to tiddly...@googlegroups.com
Hi All,

The popup mechanism not working with external windows is definitely a bug, and it would be terrific to fix it. As you’ve discovered, the two mechanisms were written without regard for one another:


I agree with Andreas that the fix is to essentially duplicate an instance of the popup mechanism for each opened window. I wonder if triggerPopup could check the ancestors of the domNode to see which window the popup is in, and route it accordingly.

Best wishes

Jeremy.



On 21 Feb 2018, at 19:07, Simon Huber <hypnotize...@gmail.com> wrote:

No - I'm not having success. Here I depend on help from above

--
You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywikide...@googlegroups.com.
To post to this group, send email to tiddly...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywikidev.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywikidev/31f5df4c-5e0b-4527-be06-7a6133f0f1f7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Simon Huber

unread,
Feb 22, 2018, 1:51:37 AM2/22/18
to tiddly...@googlegroups.com
Hi Jeremy, hi Andreas,

I'm sorry that I cannot dig into this myself, I'm not understanding the mechanism well enough right now. But I'll keep investigating so maybe at one point I can contribute.

If we think about solving this, maybe we should also think about tm-modal and tm-notify not showing in the new window? Especially the tm-modal message: if I want to delete a tiddler in a new window, the modal to confirm the action appears in the root window, tm-notify acts the same way.

I think such a new window could also be used to control a presentation or similar, where one may want the behaviour that modals and notifications get shown in the root window...

So how about changing both to show up in the window where they got triggered and adding an extension like external="no" to show them in the root window if desired?


Another thing, not directly related but maybe to include into this process: If I create a tiddler in the new window, then open its draft in the root window to edit, then save it in the root window - kind of a mess happens. I'm using two different Story-lists where I'm testing, that may be the root of the problem, but could this behaviour be fixed with the others, too?

Simon

Simon Huber

unread,
Feb 23, 2018, 3:13:59 PM2/23/18
to TiddlyWikiDev
Especially the tm-modal message: if I want to delete a tiddler in a new window, the modal to confirm the action appears in the root window, tm-notify acts the same way.

Sorry, I meant the alerts for cancelling or deleting tiddlers

Now I figured out how to register the new window at $tw.openWindows but not the main window
As I wrote before, I think that fixing just this leaves thoughts open about the alerts, modals, notifications

But I'd like to do step by step anyway

Simon
Reply all
Reply to author
Forward
0 new messages