2024 Jan 28 3:31 PM - edited 2024 Jan 28 3:34 PM
Hello everyone,
I try to use Hotkey Api file as in this blog Hotkey Api and have some questions. First Api file called Hotkey.js. How can I call the hotkeys which are located in this file in controller file to use it there?
second question: should I use switch method instead of using if condition each time and to make the code more tidy? And how to use switch method hier?
Thank you
var table = this.byId("table");
table.addEventDelegate({
onkeydown: function(oEvent) {
var selectedCheckbox = false;
var items = table.getItems();
// Check if any checkbox is selected
for (var i = 0; i < items.length; i++) {
var checkbox = items[i].getCells()[0]; // Assuming the checkbox is in the first column
if (checkbox.getSelected()) {
selectedCheckbox = true;
break;
}
}
// Execute the code only if a checkbox is selected
if (selectedCheckbox) {
if (oEvent.keyCode === 46) {
this.onRemoveRowsUi();
}
if (oEvent.ctrlKey || oEvent.metaKey) {
if (oEvent.code === "KeyC") { // Check if the pressed key is 'C'
this.onCopyPress();
}
if (oEvent.code === "KeyV") {
this.onPastePress();
}
}
}
}.bind(this)
});
Request clarification before answering.
User | Count |
---|---|
73 | |
21 | |
9 | |
8 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.