Hi, I'm building a script to edit audio file metadata, and I'd like to delete the selected files when I select files in the listView and press the Delete key. I've tried this, but the Delete key press isn't recognized.
while (true) {
var msg = dlg.GetMsg();
if (!msg.result) break;
// Trying to detect Delete key press when ListView has focus
if (msg.event === "keydown" && msg.control === "listview1") {
DOpus.Output("Key pressed on control: " + msg.control + " | Keycode: " + msg.keycode + " | Key: " + msg.key);
if (msg.key === "delete" || msg.keycode === 46) {
limpiarLista(dlg);
continue;
}
}
}
Here's how to register hotkeys in a dialog using the AddHotkey() method :
Usually, AI tends to "hallucinate" when asked for this type of tasks, which are not "mainstream" (and in fact, I think it does the same thing in everything related to coding.)
Thanks so much @errante, thanks to your links I learned a little more about events and AddHotkey() today. I ended up getting the result I wanted in the following way:
dlg.AddHotkey("limpiar", "delete");
dlg.Show();
while (true) {
msg = dlg.GetMsg();
if (!msg.result) break;
if (msg.event === "hotkey") {
if (msg.name === "limpiar") {
limpiarLista(dlg);
}
}