← Back to team overview

kicad-developers team mailing list archive

Adding global mouse shortcuts in GAL tool framework

 

Hi,

A little technical query provoked by someone else's question, which I
was unable to answer.

Say one wanted to add a global mouse shortcut, for example, double
middle-click to do "zoom-to-fit" [1].

The current mouse events are handled on a contextual basis in the
event loops for each tool. Thus, each tool handles its own clicks,
drags, etc, which generally makes sense for the basic left/right
clicks as what that does is usually highly tool-dependent. Global key
shortcuts for ACTIONs are handled at a higher level and and either
trigger a transition set by setTransitions(), or translated to an
event and caught by the current tool's event loop as their own event
(checked with evt->IsAction())

However, there appears to be no way to add a mouse click pattern to an
ACTION, thus you can't have a global double-middle-click, unless you
add an "if( evt->IsDblClick( BTN_MIDDLE))" to every event loop.

What would be the right way (if any) to approach this? I'm ignoring
for now the UI implications of presenting such a shortcut in the
hotkey dialog, implementing the "set hotkey" action, and any problems
that might arise in having it co-exist with legacy hotkeys.

Cheers,

John

[1]: https://bugs.launchpad.net/kicad/+bug/1480868


Follow ups