Plugin that uses keyboard shortcuts.

• Dec 8, 2020 - 15:33

Is it possible to make a plugin that executes keyboard shortcuts?

I'm trying to make a snare drum ruff with one click. Specifically, it's a note preceded by two 16th grace notes and a single slur spanning all three notes. I was able to do most of it with the action chain plugin, but I haven't been to get the slur to span the three notes. After adding the slur I'm able to extend with the right arrow key, but the action doesn't support the arrow key.


Comments

Keyboard shortcuts are "commands" internally, and you should be able to execute those as far as I know (I'm not a plugin expert, I've just seen this discussed here).

But I also know, there is a bug that prevents extending slurs from working in the case you describe. The best way to get the slur to connect is by ctrl+clicking the first and last note before adding the slur. So if you can mimic that in your plugin, you should be good - you want to build a list selection of two notes.

In reply to by Marc Sabatella

Thanks for the info, Marc. Yes, I got it to work like that without using a plugin.

The list selection thing sounds perfect, but I'm no expert on plugins either. I'm just familiar enough with coding that I can get away with some copy and paste and some trial and error. This may be is a bit more than I can handle. I was hoping I could just list the keyboard shortcuts.

Item {
id: pressKey
focus: true
Keys.onPressed: {
keyPressEvent(event.key);
}

function keyPressEvent(key) {

    if (key === Qt.Key_Up) rotatedLeft();
    if (key === Qt.Key_Down) rotatedRight();
    if (key === Qt.Key_Left) move(- 1);

if (key === Qt.Key_Right) move(1);
if (key === Qt.Key_Space) dropDown();
if (key === Qt.Key_Home) start();
if (key === Qt.Key_End) quit();
}

In reply to by bazhenoff

Thanks for taking the time to do this. When I posted the question, I was hoping someone had an easy answer. Don't have enough time to learn Qml and I wouldn't feel right asking you to do all the work. I have done some coding in the past, but this is a little over my head. If there's a simple thing you can explain, like putting a (replace this text) kind of thing in the code, that would be great, but please, only if it's easy for you. I don't want to take too much of your time.

Thanks again.

In reply to by jimdooley07

The posted code however does not do what you were asking for.
The posted code steals the keypress focus which allows your plugin to respond to them. What it doesn't do is send that keypress to the score to emulate what should normally happen at all.

I haven't used it myself, but quite recently (3.5?) the plugins API includes ways of reading/modifying a selection. This might help you to select the start- and end-note only, after which you can call the slur command.

In reply to by bazhenoff

@bazhenoff,
I can read the Russian words but rely mostly on a translator. One trick I use is to select an item then switch from English to Russian to see the Russian word for it in the status bar, especially a word like Slur that has so many meanings in English. Musical terms are very often translated wrong with automatic translators.

Do you still have an unanswered question? Please log in first to post your question.