From 124b49456a4dc2b75ecab17e9be5180464e4d9b1 Mon Sep 17 00:00:00 2001 From: "jeremy@jermolene.com" Date: Sat, 21 Aug 2021 12:50:38 +0100 Subject: [PATCH] MessageCatcher: Expose lists of the message property names --- core/modules/widgets/messagecatcher.js | 11 +++++++---- .../tw5.com/tiddlers/widgets/MessageCatcherWidget.tid | 2 ++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/core/modules/widgets/messagecatcher.js b/core/modules/widgets/messagecatcher.js index 51da35772..a1346cde4 100644 --- a/core/modules/widgets/messagecatcher.js +++ b/core/modules/widgets/messagecatcher.js @@ -42,18 +42,21 @@ MessageCatcherWidget.prototype.render = function(parent,nextSibling) { // Collect all the event properties into variables var collectProps = function(obj,prefix) { prefix = prefix || ""; - var props = {}; + var props = {}, + names = []; $tw.utils.each(obj,function(value,name) { if(["string","boolean","number"].indexOf(typeof value) !== -1) { - props[prefix + name] = value.toString(); + names.push(name); + props[prefix + "-" + name] = value.toString(); } }); + props["list-" + prefix] = $tw.utils.stringifyList(names); return props; }; var variables = $tw.utils.extend( {}, - collectProps(event.paramObject,"event-paramObject-"), - collectProps(event,"event-"), + collectProps(event.paramObject,"event-paramObject"), + collectProps(event,"event"), { modifier: $tw.keyboardManager.getEventModifierKeyDescriptor(event) }); diff --git a/editions/tw5.com/tiddlers/widgets/MessageCatcherWidget.tid b/editions/tw5.com/tiddlers/widgets/MessageCatcherWidget.tid index 7f3e566e6..c55a31eef 100644 --- a/editions/tw5.com/tiddlers/widgets/MessageCatcherWidget.tid +++ b/editions/tw5.com/tiddlers/widgets/MessageCatcherWidget.tid @@ -25,7 +25,9 @@ The message catcher widget |!Variables |!Description | |`event-*` |All string-based properties of the `event` object, with the names prefixed with `event-` | +|`list-event` |A list of the names of each the string-based properties of the `event` object (the names are not prefixed with `event-`) | |`event-paramObject-*` |All string-based properties of the `event.paramObject` object, with the names prefixed with `event-paramObject-` | +|`list-event-paramObject` |A list of the names of each the string-based properties of the `event.paramObject` object (the names are not prefixed with `event-paramObject-`) | |`modifier` |For messages that originated with browser events, the modifier keys that were pressed when the event was fired. The possible modifiers are ''normal'' (no modifiers), ''ctrl'', ''ctrl-alt'', ''ctrl-shift'', ''alt'', ''alt-shift'', ''shift'' and ''ctrl-alt-shift'' | ! Example