<div dir="ltr"><div><div><div>Hi.<br><br>I'm having trouble getting rid of default keypress behavior.  I've had considerably less luck with the documentation/examples and with google than usual.<br><br>I'm using python 2.6.8 and vtk-5.10.1.  I've been working from the example here:<br><br><a href="http://www.vtk.org/Wiki/index.php?title=VTK/Examples/Python/Interaction/MouseEventsObserver">http://www.vtk.org/Wiki/index.php?title=VTK/Examples/Python/Interaction/MouseEventsObserver</a><br><br></div>If I run that directly, it works, and hit 'w, it switches to wireframe.  I want to disconnect any default key handling so that eventually I can substitute my own.  That is, eventually, I want to make 'w' do something completely different.<br><br></div><div>If I edit the end of that example to look like this:<br><br></div><div>interactor.RemoveObservers('KeyPressEvent')  #  <-- I ADDED THIS<br>interactor.RemoveObservers('LeftButtonPressEvent')<br>interactor.AddObserver('LeftButtonPressEvent', DummyFunc1, 1.0)<br>interactor.AddObserver('LeftButtonPressEvent', DummyFunc2, -1.0)<br>interactor.Initialize()<br>interactor.Start()<br><br></div></div><div>and run again, pressing 'w' still switches to wireframe.   I was hoping that by removing all KeyPressEvent observers, the program would no longer respond to keypresses.  Why does 'w' still produce a wireframe image, and how do I disable 'w' (so I can override it with my own action)?<br><br></div><div>In trying to debug this, I figured I'd check whether 'KeyPressEvent' really is the correct name.  If I go back to the original example code, and change the end to look like this:<br><br>def keypress(obj, ev):  # <-- I ADDED THIS<br>    print "keypress!"      # < -- I ADDED THIS<br> <br>interactor.AddObserver('KeyPressEvent', keypress)  # <-- I ADDED THIS<br>interactor.RemoveObservers('LeftButtonPressEvent')<br>interactor.AddObserver('LeftButtonPressEvent', DummyFunc1, 1.0)<br>interactor.AddObserver('LeftButtonPressEvent', DummyFunc2, -1.0)<br>interactor.Initialize()<br>interactor.Start()<br><br>then I see "keypress!" every time I press a key.  This tells me that 'KeyPressEvent' is the correct name. So I'm baffled.  I think I'm removing all 'KeyPressEvent' observers, yet 'w' still switches to wireframe.   What am I doing wrong?<br><br>Many thanks for any help.<br><br>Greg<br></div><div><div><br></div></div></div>