Jump to content
  • Advertisement
Sign in to follow this  
imagenesis

How to handle set of keyboard shortcuts (Statemachine eval onEvent vs chained Event handlers)

This topic is 393 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

This question is within the context of systems implemented to handle (chained) shortcuts for a viewport that generally execute 2 functionalities: events responding to a shortcut press and functionality that depends on the keydown state of shortcuts.

1. Is there any literature or documentation that discusses implementing such a shortcut handling systems?
2. My position, is of the considered patterns below, #2 is correct, however are there any distinct advantages or explicit decision to use a state-machine like handling system as described in #1?
3. Of the following software, please let me know if you have any insight on their implementations:

a) Blender
b) GIMP
c) Inkscape

Any other source available robust implementations that you know of.

Consider the following 2 psuedocode patterns

My position is that the correct and effecient implementation is to maintain the explicit handler for a recurring event, eg the second implementation (#2). However, there is likely a set of developers who advocate a state-machine like implementation of #1.

    viewport.addEvent(MOUSE_MOVE,mouseMoveHandler)

    function mouseMoveHandler(e) {
        if(shortCutsManager.getKey(DELETE_KEY)) {
            doDeleteUnderMouse();
        } else if(shortCutsManager.getKey(DRAG_KEY)) {
            dragMouseMove();
        }
    }

or something like:

    foreach(k in shortCutsManager.mouseMoveKeys.keys()) {
        var keyContext=shortCutManagers.mouseMoveKeys.get(k);
        viewport.addEvent(MOUSE_MOVE,keyContext.mouseMoveHandler);
    }
    function deleteKey_mouseMoveHandler(e) {
        viewport.removeEvent(MOUSE_MOVE,currentMouseMoveHandler);
        currentMouseMoveHandler=deleteKey_mouseMoveHandler;
        doDeleteUnderMouse();
    }

 




	 
Edited by imagenesis

Share this post


Link to post
Share on other sites
Advertisement

It would be exceedingly helpful (for me at least) if you could describe what the user actually is doing in these scenarios. For instance, are you talking about modifier keys? (The usual set being Ctrl, Shift, Alt, etc.) Are you talking about key combinations? (Ctrl+A, Alt+Q) Are you talking about chords? (Ctrl+K+N to use a popular Visual Studio chord)

Or maybe a single system that handles all of these input forms?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!