<div dir="ltr"><div>Hi, David.<br><br>Many, many thanks! That's exactly what I needed, and it's working perfectly.<br><br></div>Greg<br><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Oct 4, 2014 at 9:52 AM, David Cole <span dir="ltr"><<a href="mailto:DLRdave@aol.com" target="_blank">DLRdave@aol.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The keypresses VTK handles by default are documented here:<br>
<br>
<a href="http://www.vtk.org/doc/release/5.10/html/classvtkInteractorStyle.html#details" target="_blank">http://www.vtk.org/doc/release/5.10/html/classvtkInteractorStyle.html#details</a><br>
<br>
(The 5.10 documentation, since that's the version you said you're using...)<br>
<br>
The implementation for handling those keys is in the method<br>
vtkInteractorStyle::OnChar, which is documented here:<br>
<br>
<a href="http://www.vtk.org/doc/release/5.10/html/classvtkInteractorStyle.html#a4357cd197cdf5c2d9ff8821cb4a50d82" target="_blank">http://www.vtk.org/doc/release/5.10/html/classvtkInteractorStyle.html#a4357cd197cdf5c2d9ff8821cb4a50d82</a><br>
<br>
The event triggering OnChar is the CharEvent, though, not the<br>
KeyPressEvent. Try removing observers for CharEvent instead.<br>
<br>
<br>
HTH,<br>
David C.<br>
<div><div class="h5"><br>
On Fri, Oct 3, 2014 at 9:53 PM, Greg Schussman <<a href="mailto:greg.schussman@gmail.com">greg.schussman@gmail.com</a>> wrote:<br>
> Hi.<br>
><br>
> I'm having trouble getting rid of default keypress behavior. I've had<br>
> considerably less luck with the documentation/examples and with google than<br>
> usual.<br>
><br>
> I'm using python 2.6.8 and vtk-5.10.1. I've been working from the example<br>
> here:<br>
><br>
> <a href="http://www.vtk.org/Wiki/index.php?title=VTK/Examples/Python/Interaction/MouseEventsObserver" target="_blank">http://www.vtk.org/Wiki/index.php?title=VTK/Examples/Python/Interaction/MouseEventsObserver</a><br>
><br>
> If I run that directly, it works, and hit 'w, it switches to wireframe. I<br>
> want to disconnect any default key handling so that eventually I can<br>
> substitute my own. That is, eventually, I want to make 'w' do something<br>
> completely different.<br>
><br>
> If I edit the end of that example to look like this:<br>
><br>
> 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>
> and run again, pressing 'w' still switches to wireframe. I was hoping that<br>
> by removing all KeyPressEvent observers, the program would no longer respond<br>
> to keypresses. Why does 'w' still produce a wireframe image, and how do I<br>
> disable 'w' (so I can override it with my own action)?<br>
><br>
> In trying to debug this, I figured I'd check whether 'KeyPressEvent' really<br>
> is the correct name. If I go back to the original example code, and change<br>
> 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<br>
> 'KeyPressEvent' is the correct name. So I'm baffled. I think I'm removing<br>
> all 'KeyPressEvent' observers, yet 'w' still switches to wireframe. What<br>
> am I doing wrong?<br>
><br>
> Many thanks for any help.<br>
><br>
> Greg<br>
><br>
><br>
</div></div>> _______________________________________________<br>
> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
><br>
> Visit other Kitware open-source projects at<br>
> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
><br>
> Please keep messages on-topic and check the VTK FAQ at:<br>
> <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
><br>
> Follow this link to subscribe/unsubscribe:<br>
> <a href="http://public.kitware.com/mailman/listinfo/vtkusers" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br>
><br>
</blockquote></div><br></div>