mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 10:07:19 +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:
parent
a0bd93c596
commit
00ff0d6fa0
@ -284,6 +284,16 @@ KeyboardManager.prototype.checkKeyDescriptors = function(event,keyInfoArray) {
|
||||
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() {
|
||||
return $tw.wiki.getTiddlersWithTag("$:/tags/KeyboardShortcut");
|
||||
};
|
||||
|
@ -91,7 +91,8 @@ ButtonWidget.prototype.render = function(parent,nextSibling) {
|
||||
handled = true;
|
||||
}
|
||||
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) {
|
||||
event.preventDefault();
|
||||
|
@ -132,8 +132,7 @@ DroppableWidget.prototype.handleDropEvent = function(event) {
|
||||
|
||||
DroppableWidget.prototype.performActions = function(title,event) {
|
||||
if(this.droppableActions) {
|
||||
var modifierKey = event.ctrlKey && ! event.shiftKey ? "ctrl" : event.shiftKey && !event.ctrlKey ? "shift" :
|
||||
event.ctrlKey && event.shiftKey ? "ctrl-shift" : "normal" ;
|
||||
var modifierKey = $tw.keyboardManager.getEventModifierKeyDescriptor(event);
|
||||
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.
|
||||
|
||||
|!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 |
|
||||
|message |The name of the [[widget message|Messages]] to send when the button is clicked |
|
||||
|param |The optional parameter to the message |
|
||||
|
Loading…
Reference in New Issue
Block a user