mirror of
				https://github.com/Jermolene/TiddlyWiki5
				synced 2025-10-30 23:23:02 +00:00 
			
		
		
		
	Add modifier variable to button actionstring (#4671)
* Add modifier variable to button actionstring * Update ButtonWidget.tid * Update droppable.js * Create getEventModifierKeyDescriptor method in keyboard.js * Update droppable.js * Update button.js
This commit is contained in:
		| @@ -284,6 +284,16 @@ KeyboardManager.prototype.checkKeyDescriptors = function(event,keyInfoArray) { | |||||||
| 	return false; | 	return false; | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | KeyboardManager.prototype.getEventModifierKeyDescriptor = function(event) { | ||||||
|  | 	return event.ctrlKey && !event.shiftKey && !event.altKey ? "ctrl" :  | ||||||
|  | 		event.shiftKey && !event.ctrlKey && !event.altKey? "shift" :  | ||||||
|  | 		event.ctrlKey && event.shiftKey && !event.altKey ? "ctrl-shift" :  | ||||||
|  | 		event.altKey && !event.shiftKey && !event.ctrlKey ? "alt" :  | ||||||
|  | 		event.altKey && event.shiftKey && !event.ctrlKey ? "alt-shift" :  | ||||||
|  | 		event.altKey && event.ctrlKey && !event.shiftKey ? "ctrl-alt" :  | ||||||
|  | 		event.altKey && event.shiftKey && event.ctrlKey ? "ctrl-alt-shift" : "normal"; | ||||||
|  | }; | ||||||
|  |  | ||||||
| KeyboardManager.prototype.getShortcutTiddlerList = function() { | KeyboardManager.prototype.getShortcutTiddlerList = function() { | ||||||
| 	return $tw.wiki.getTiddlersWithTag("$:/tags/KeyboardShortcut"); | 	return $tw.wiki.getTiddlersWithTag("$:/tags/KeyboardShortcut"); | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -91,7 +91,8 @@ ButtonWidget.prototype.render = function(parent,nextSibling) { | |||||||
| 			handled = true; | 			handled = true; | ||||||
| 		} | 		} | ||||||
| 		if(self.actions) { | 		if(self.actions) { | ||||||
| 			self.invokeActionString(self.actions,self,event); | 			var modifierKey = $tw.keyboardManager.getEventModifierKeyDescriptor(event); | ||||||
|  | 			self.invokeActionString(self.actions,self,event,{modifier: modifierKey}); | ||||||
| 		} | 		} | ||||||
| 		if(handled) { | 		if(handled) { | ||||||
| 			event.preventDefault(); | 			event.preventDefault(); | ||||||
|   | |||||||
| @@ -132,8 +132,7 @@ DroppableWidget.prototype.handleDropEvent  = function(event) { | |||||||
|  |  | ||||||
| DroppableWidget.prototype.performActions = function(title,event) { | DroppableWidget.prototype.performActions = function(title,event) { | ||||||
| 	if(this.droppableActions) { | 	if(this.droppableActions) { | ||||||
| 		var modifierKey = event.ctrlKey && ! event.shiftKey ? "ctrl" : event.shiftKey && !event.ctrlKey ? "shift" :  | 		var modifierKey = $tw.keyboardManager.getEventModifierKeyDescriptor(event); | ||||||
| 				event.ctrlKey && event.shiftKey ? "ctrl-shift" : "normal" ; |  | ||||||
| 		this.invokeActionString(this.droppableActions,this,event,{actionTiddler: title, modifier: modifierKey}); | 		this.invokeActionString(this.droppableActions,this,event,{actionTiddler: title, modifier: modifierKey}); | ||||||
| 	} | 	} | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -24,7 +24,7 @@ The integrated actions are provided as a shortcut for invoking common actions. T | |||||||
| The content of the `<$button>` widget is displayed within the button. | The content of the `<$button>` widget is displayed within the button. | ||||||
|  |  | ||||||
| |!Attribute |!Description | | |!Attribute |!Description | | ||||||
| |actions |A string containing ActionWidgets to be triggered when the key combination is detected | | |actions |A string containing ActionWidgets to be triggered when the key combination is detected. <<.from-version "5.1.23">> the <<.def "modifier">> variable lists the modifier keys that are pressed when the action is invoked. The possible modifiers are ''ctrl'', ''ctrl-alt'', ''ctrl-shift'', ''alt'', ''alt-shift'', ''shift'' and ''ctrl-alt-shift'' | | ||||||
| |to |The title of the tiddler to navigate to | | |to |The title of the tiddler to navigate to | | ||||||
| |message |The name of the [[widget message|Messages]] to send when the button is clicked | | |message |The name of the [[widget message|Messages]] to send when the button is clicked | | ||||||
| |param |The optional parameter to the message | | |param |The optional parameter to the message | | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Simon Huber
					Simon Huber