1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-02-17 11:30:02 +00:00

Droppable widget - passing modifiers as variables (#3167)

* pass the modifier keys as variables

* Update DroppableWidget.tid

* Create modifier Variable.tid

* closing bracket got lost
This commit is contained in:
BurningTreeC 2018-03-14 18:52:13 +01:00 committed by Jeremy Ruston
parent de6e0d1c1e
commit c9b8319801
3 changed files with 21 additions and 2 deletions

View File

@ -128,7 +128,9 @@ DroppableWidget.prototype.handleDropEvent = function(event) {
DroppableWidget.prototype.performActions = function(title,event) { DroppableWidget.prototype.performActions = function(title,event) {
if(this.droppableActions) { 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});
} }
}; };

View File

@ -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 |

View File

@ -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 | |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 | |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. If multiple items are dropped then the actions are performed repeatedly, once for each dropped item.