Kent:<br><br>Thanks for reporting the bug.<br><br><div><span class="gmail_quote">On 12/17/07, <b class="gmail_sendername">kent williams</b> <<a href="mailto:nkwmailinglists@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
nkwmailinglists@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">The documentation says any call to SetTranslation will override any
<br>previous call to SetTranslation. This appears not to be the case, or<br>maybe I haven't yet figured out the magic incantation yet.<br><br> vtkWidgetEventTranslator *xlat = this->m_ContourWidget->GetEventTranslator();
<br>xlat->SetTranslation(vtkCommand::KeyPressEvent,<br> vtkEvent::ControlModifier,<br> 101,1,NULL,vtkWidgetEvent::AddFinalPoint);<br> xlat->SetTranslation(vtkCommand::NoEvent,
<br> vtkEvent::NoModifier,<br> 47,1,NULL,vtkWidgetEvent::Delete);</blockquote><div><br>The translator now works as reported.<br>
<a href="http://public.kitware.com/cgi-bin/viewcvs.cgi/Widgets/vtkWidgetEventTranslator.cxx?r1=1.2&r2=1.3">http://public.kitware.com/cgi-bin/viewcvs.cgi/Widgets/vtkWidgetEventTranslator.cxx?r1=1.2&r2=1.3</a><br>
<a href="http://public.kitware.com/cgi-bin/viewcvs.cgi/Widgets/vtkWidgetEventTranslator.h?r1=1.4&r2=1.5">http://public.kitware.com/cgi-bin/viewcvs.cgi/Widgets/vtkWidgetEventTranslator.h?r1=1.4&r2=1.5</a><br><br>
Note that it will not overwrite the existing translation, as it could (and will break existing widgets). I can explain if needed. <br><br>However, I've just added an explicit way to remove a translation and add your translation in...
<br><br>such as:<br><br> eventTranslator->RemoveTranslation( vtkCommand::RightButtonPressEvent );<br> eventTranslator->SetTranslation( <br> vtkCommand::KeyPressEvent,<br> vtkEvent::NoModifier, 103, 0, NULL,
<br> vtkWidgetEvent::AddFinalPoint );<br><br>Let me know if this works fine.<br>
</div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Also, the Delete Point binding is really strange. In the CVS version<br>of the widget, hitting 'Ctrl', 'Shift', and on Mac, the CloverLeaf Key
<br>deletes the last point during contour definition, and the currently<br>selected point after a contour is closed. This appears to be a bug,</blockquote><div><br>Yes. This is a nasty bug in VTK. With the VTK EventTranslators and comparisons in general... I intend fixing this when I find time...
<br><br>Here's an expostulation of the bug.. <br><br>A keyboard event from X has a "keysym" and a "keycode". The fact of the matter is that BOTH are needed to uniquely identify a key. <br>However the problem is that VTK widgets erroneously assume that just the "KeyCode" suffices to uniquely identify them.
<br>You've yourself written such a line above...<br> eventTranslator->SetTranslation( vtkCommand::KeyPressEvent, vtkEvent::NoModifier, 103, 0, NULL, vtkWidgetEvent::AddFinalPoint );<br><br>The NULL here instructs the translator to ignore the keysymbol.
<br><br>Now, the control, alt, spacebar etc... have a KeySym, but their KeyCode is 0. <br><br>Hence when the control key is pressed, the event translators, ingore the keycode in comparison (since its NULL, IMHO that's the first bug and the easy one).
<br>And comparison with any event that has a keysym of NULL yields true, by virtue of something being null in each event. See operator== in vtkEvent.h (<a href="http://public.kitware.com/cgi-bin/viewcvs.cgi/Widgets/vtkEvent.cxx?annotate=1.7">
http://public.kitware.com/cgi-bin/viewcvs.cgi/Widgets/vtkEvent.cxx?annotate=1.7</a>)<br><br>As a result comparison with the first keypress event is a success and the widgets start doing bogus things...<br><br>We should really be using XLookUpString(..) and doing string comparisons in there......
<br><br>HTH<br>-- <br>Karthik Krishnan<br>R&D Engineer,<br>Kitware Inc.<br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">_______________________________________________
<br>vtk-developers mailing list
<br><a href="mailto:vtk-developers@vtk.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">vtk-developers@vtk.org</a><br><a href="http://www.vtk.org/mailman/listinfo/vtk-developers" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
http://www.vtk.org/mailman/listinfo/vtk-developers</a><br></blockquote></div><br><br clear="all">
<br><br>