From 77a929faa3a33768e52cf2a34ecbef9c554a6a7b Mon Sep 17 00:00:00 2001 From: "jeremy@jermolene.com" Date: Tue, 21 Apr 2020 22:19:03 +0100 Subject: [PATCH] ActionPopup widget: Add ability to cancel all popups --- core/modules/widgets/action-popup.js | 4 +++- editions/tw5.com/tiddlers/widgets/ActionPopupWidget.tid | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/core/modules/widgets/action-popup.js b/core/modules/widgets/action-popup.js index 84fcec821..af17b3f51 100644 --- a/core/modules/widgets/action-popup.js +++ b/core/modules/widgets/action-popup.js @@ -57,7 +57,7 @@ Invoke the action associated with this widget ActionPopupWidget.prototype.invokeAction = function(triggeringWidget,event) { // Trigger the popup var popupLocationRegExp = /^\((-?[0-9\.E]+),(-?[0-9\.E]+),(-?[0-9\.E]+),(-?[0-9\.E]+)\)$/, - match = popupLocationRegExp.exec(this.actionCoords); + match = popupLocationRegExp.exec(this.actionCoords || ""); if(match) { $tw.popup.triggerPopup({ domNode: null, @@ -70,6 +70,8 @@ ActionPopupWidget.prototype.invokeAction = function(triggeringWidget,event) { title: this.actionState, wiki: this.wiki }); + } else { + $tw.popup.cancel(0); } return true; // Action was invoked }; diff --git a/editions/tw5.com/tiddlers/widgets/ActionPopupWidget.tid b/editions/tw5.com/tiddlers/widgets/ActionPopupWidget.tid index c1b7003d3..17fd51531 100644 --- a/editions/tw5.com/tiddlers/widgets/ActionPopupWidget.tid +++ b/editions/tw5.com/tiddlers/widgets/ActionPopupWidget.tid @@ -1,13 +1,13 @@ caption: action-popup created: 20200303114556528 -modified: 20200303114556528 +modified: 20200421221304177 tags: Widgets ActionWidgets title: ActionPopupWidget type: text/vnd.tiddlywiki ! Introduction -The ''action-popup'' widget is an [[action widget|ActionWidgets]] that triggers the display of a popup defined via a state tiddler. ActionWidgets are used within triggering widgets such as the ButtonWidget. +The ''action-popup'' widget is an [[action widget|ActionWidgets]] that triggers the display of a popup defined via a state tiddler, or clears all displayed popups. ActionWidgets are used within triggering widgets such as the ButtonWidget. ! Content and Attributes @@ -17,6 +17,8 @@ The ''action-popup'' widget is invisible. Any content within it is ignored. |$state |The title of the state tiddler for the popup | |$coords |Optional coordinates for the handle to which popup is positioned (in the format `(x,y,w,h)`) | +<<.from-version "5.1.23">> If the ''$coords'' attribute is missing or empty then all popups are cancelled. + ! Examples Here is an example of button that triggers the "more" button in the sidebar "Tools" tab. You may need to scroll to see the popup