sofa-framework / sofa

Real-time multi-physics simulation with an emphasis on medical simulation.
https://www.sofa-framework.org
GNU Lesser General Public License v2.1
934 stars 312 forks source link

Invalid behavior in how runSofa propagates keys pressed to the scene. #3384

Open damienmarchal opened 2 years ago

damienmarchal commented 2 years ago

Problem

Description runSofa does not propagate correctly the key pressed & release event because of the weird use of the the CTRL combination.

Steps to reproduce

import Sofa

class Test(Sofa.Core.Controller):
    def __init__(self, *args, **kwargs):
        Sofa.Core.Controller.__init__(self,*args, **kwargs)

    def onKeypressedEvent(self, event):
        print("KEY PRESSED", event)

    def onKeyreleasedEvent(self, event):
        print("KEY RELEASED", event)

def createScene(root):
    root.addObject(Test(name="Hello"))

Start a simulation and keep pressing CTRL+A key. It will print!

KEY PRESSED: {...}
KEY RELEASED: {...}
...  /// lot of repetition
KEY PRESSED: {...}
KEY RELEASED: {...}

Expected behavior It should print a single KEY PRESSED & KEY RELEASED.

damienmarchal commented 1 year ago

Again one more use case for that feature: https://github.com/sofa-framework/SofaPython3/pull/184