$(document).keydown(function(evt){
if (evt.keyCode==83 && (evt.ctrlKey)){
evt.preventDefault();
alert('worked');
}
});
sap.ui.define([
"sap/ui/base/Object"
], function(ui5Object) {
"use strict";
var HotkeyInterface = ui5Object.extend("sap.test.listreport.util.hotkeyInterface", {
constructor: function() {
// Nothing
},
bindHotKeys: function(combinations) {
// remove the old key combinations that are buffered
if(this.tempCombinations){
this.tempCombinations.forEach(function(mItem) {
this.unBindHotKey(mItem.keyCombination);
}, this);
}
// Buffer the combinations for removing later
this.tempCombinations = combinations;
combinations.forEach(function(mItem) {
// Now call the actual binding
this.bindHotKey(mItem.keyCombination, mItem.control, mItem.fnHandler, mItem.hanlder);
}, this);
},
bindHotKey: function(keyCombination, control, fnHandler, hanlder) {
$(document).bind("keydown." + this.getNameSpace(keyCombination), keyCombination, function(oEvent) {
if (control && control.getDomRef() && control.getDomRef().getBoundingClientRect()) {
// Check if the control is visible in DOM currently,
// sometimes,the control might be hidden becuase of a tab change or view change
var aMargin = control.getDomRef().getBoundingClientRect();
if (aMargin.width) {// If the width is availble, then it is visible
fnHandler.call(this, oEvent, control);
}
}
}.bind(hanlder));
},
unBindHotKeys: function(keyCombinations) {
// Remove the hotkeys
keyCombinations.forEach(function(mItem) {
this.unBindHotKey(mItem.keyCombination);
}, this);
},
unBindHotKey: function(keyCombination) {
$(document).unbind("keydown." + this.getNameSpace(keyCombination));
},
getNameSpace: function(keyCombination) {
// Create a unique key for the hotkey we are using
return "pocApplication_" + keyCombination.replace("+", "_");
}
});
return {
getInstance: function() {
// Singleton
if (!this.instance) {
this.instance = new HotkeyInterface();
}
return this.instance;
}
};
});
this.hotKeyHanlders = [{
keyCombination: "Alt+f1",
control: this.getView().byId("inputPopup"),
fnHandler: this.focusOnSearchFields,
hanlder: this
}, {
keyCombination: "Alt+f2",
control: this.getView().byId("idOrderInput"),
fnHandler: this.focusOnSearchFields,
hanlder: this
}, {
keyCombination: "F8",
control: this.getView().byId("idPostDocuments"),
fnHandler: this.handleHotKeyPost,
hanlder: this
}];
hotkeyInterface.getInstance().bindHotKeys(this.hotKeyHanlders);
focusOnSearchFields: function(oEvent, oControl) {
oEvent.preventDefault();
oControl.focus();
},
handleHotKeyPost: function(oEvent, oControl) {
oEvent.preventDefault();
this.postDocuments();
},
unBindAllHotKeys: function() {
hotkeyInterface.getInstance()).unBindHotKeys(this.hotKeyHanlders);
},
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
10 | |
8 | |
7 | |
5 | |
4 | |
4 | |
4 | |
3 | |
3 | |
3 |