Shortcuts for buttons from gui.GeDialog



  • Hello!
    I'm so happy with the C4D python API, it allows to create scripts, plugins, interfaces, menus, etc, very easily!

    My question is:
    Is it possible to assign shortcuts to these buttons from gui.GeDialog ?
    alt text

    If not, I think I could achieve that by writing separate scripts to perform the same action the button does, so it appear in the customize commands window.

    Thanks in advance!

    Flavio



  • You cannot assign shortcuts to buttons.
    An alternative solution (which I have used in the past) is to create a CommandData plugin for each button, and let the CommandData::Execute call the button. Or instead of a CommandData plugin you could also create a separate script for each button.
    Either way, these can then be assigned a shortcut.


  • Global Moderator

    Hi @FlavioDiniz, as C4DS said the correct way to handle shortcut is to create a command for them.

    Beside of that in this CommandData.Execute you could do two things:

    • Implement the action (only possible if you don't need any data stored in the GUI, otherwise, your GUI have to expose them in any kind of form).
    • Send a CoreMesage to the dialog, then in your dialog, catch this message and do the logic (The GUI have to be open).

    With that's said, you could also listen for Message BFM_INPUT_DEVICE and especially BFM_INPUT_KEYBOARD. Then react to the keyboard, as it's explained in the Mouse and Keyboard Interaction C++ Manual.
    But in this case, it will not show up in the customize commands window.

    If you have any question please let me know!
    Cheers,
    Maxime.



  • Thanks a lot @C4DS @m_adam !
    So I think it's better to create separate CommandDataplugins to perform the same action of each button, it's less complicated and allow the user to change the keyboard shortcuts and exclude the need of the GUI being always open.

    Although the m_adam suggestions may be useful for other plugins ideas I have. I'll try it later.
    Thanksss !