<div dir="ltr">What I did in my Qt program was - used a toggle button on the toolbar to enable and disable the distance widget.<br><br>Jothy<br><br><div class="gmail_quote">On Tue, Sep 21, 2010 at 3:20 PM, Leonardo M. Ramé <span dir="ltr"><<a href="mailto:l.rame@griensu.com">l.rame@griensu.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Hi, I created a vtkDistanceWidget, and added an observer to catch the<br>
"delete" key on that widget, to be able to delete it from the scene.<br>
<br>
The problem is that key events are captured for the whole interactor,<br>
and not for my specific widget. How can I know what was the active<br>
widget at the moment of pressing the delete key?.<br>
<br>
<br>
This is my code:<br>
<br>
void widgetPickObserver(vtkObject* caller, unsigned long eid, void* clientdata, void *calldata)<br>
{<br>
qDebug(static_cast<vtkRenderWindowInteractor*>(caller)->GetKeySym());<br>
}<br>
<br>
void myClass::addDistanceWidget()<br>
{<br>
distanceWidget = vtkDistanceWidget::New();<br>
distanceWidget->SetInteractor(this->GetInteractor());<br>
distanceWidget->CreateDefaultRepresentation();<br>
static_cast<vtkDistanceRepresentation *>(distanceWidget->GetRepresentation())->SetLabelFormat("%-#6.3g mm");<br>
<br>
vtkSmartPointer<vtkCallbackCommand> Callback = vtkSmartPointer<vtkCallbackCommand>::New();<br>
Callback->SetCallback(widgetPickObserver);<br>
Callback->SetClientData(distanceWidget);<br>
<br>
distanceWidget->GetInteractor()->AddObserver(vtkCommand::KeyPressEvent, Callback);<br>
distanceWidget->On();<br>
}<br>
<br>
<br>
--<br>
Leonardo M. Ramé<br>
<a href="http://leonardorame.blogspot.com" target="_blank">http://leonardorame.blogspot.com</a><br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <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: <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://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
</blockquote></div><br></div>