From c9b8319801861bdd5b7459c3f7cc8e1f50f4975d Mon Sep 17 00:00:00 2001 From: BurningTreeC Date: Wed, 14 Mar 2018 18:52:13 +0100 Subject: [PATCH] Droppable widget - passing modifiers as variables (#3167) * pass the modifier keys as variables * Update DroppableWidget.tid * Create modifier Variable.tid * closing bracket got lost --- core/modules/widgets/droppable.js | 4 +++- .../tiddlers/variables/modifier Variable.tid | 14 ++++++++++++++ .../tw5.com/tiddlers/widgets/DroppableWidget.tid | 5 ++++- 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 editions/tw5.com/tiddlers/variables/modifier Variable.tid diff --git a/core/modules/widgets/droppable.js b/core/modules/widgets/droppable.js index f2e0ee7b7..dabb4c259 100644 --- a/core/modules/widgets/droppable.js +++ b/core/modules/widgets/droppable.js @@ -128,7 +128,9 @@ DroppableWidget.prototype.handleDropEvent = function(event) { DroppableWidget.prototype.performActions = function(title,event) { if(this.droppableActions) { - this.invokeActionString(this.droppableActions,this,event,{actionTiddler: title}); + var modifierKey = event.ctrlKey && ! event.shiftKey ? "ctrl" : event.shiftKey && !event.ctrlKey ? "shift" : + event.ctrlKey && event.shiftKey ? "ctrl-shift" : "normal" ; + this.invokeActionString(this.droppableActions,this,event,{actionTiddler: title, modifier: modifierKey}); } }; diff --git a/editions/tw5.com/tiddlers/variables/modifier Variable.tid b/editions/tw5.com/tiddlers/variables/modifier Variable.tid new file mode 100644 index 000000000..44c4c2077 --- /dev/null +++ b/editions/tw5.com/tiddlers/variables/modifier Variable.tid @@ -0,0 +1,14 @@ +tags: Variables [[Core Variables]] +title: modifier Variable +type: text/vnd.tiddlywiki + +Within the ''action'' string of the DroppableWidget, the <<.def modifier>> [[variable|Variables]] contains the modifier key(s) held during the drag-process. +The possible keys are ''ctrl'', ''shift'' or both ''ctrl'' and ''shift'' + +The variable contains a string that identifies the keys: + +|Modifier Key |Variable Content |h +|ctrl |ctrl | +|shift |shift | +|ctrl+shift |ctrl-shift | +|no modifier (normal drag) |normal | diff --git a/editions/tw5.com/tiddlers/widgets/DroppableWidget.tid b/editions/tw5.com/tiddlers/widgets/DroppableWidget.tid index 19f1f9fc8..10c58e4c0 100644 --- a/editions/tw5.com/tiddlers/widgets/DroppableWidget.tid +++ b/editions/tw5.com/tiddlers/widgets/DroppableWidget.tid @@ -31,7 +31,10 @@ See DragAndDropMechanism for an overview. |class |Optional CSS classes to assign to the draggable element. The class `tc-droppable` is added automatically, and the class `tc-dragover` is applied while an item is being dragged over the droppable element | |tag |Optional tag to override the default of a "div" element when the widget is rendered in block mode, or a "span" element when it is rendered in inline mode | -Within the action string, the [[actionTiddler Variable]] contains the title of the item being dropped. +Within the action string, there are two Variables generated by the DroppableWidget: + +* The [[actionTiddler Variable]] contains the title of the item being dropped +* The [[modifier Variable]] contains the Modifier Key held while dragging (can be normal, ctrl, shift or ctrl-shift) If multiple items are dropped then the actions are performed repeatedly, once for each dropped item.