<div dir="ltr"><div><div>Yes. Subclass of InteractorStyle has no problem getting both left button down and up events. <br><br></div>However, my question was why the render window interactor only "eats" left button up, but not the left button down event. Should the render window interactor also invokes the button up observers if possible, or just remove invoking the button down observers? This will make sure up and down are handled together or otherwise strange behaviors may occur.<br>
<br>Thanks,<br></div>Mengda<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Dec 6, 2013 at 6:40 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">Hi Mengda,<br>
<br>
This is not really "broken" -- it's more "by design," but with an unfortunately non-obvious way to do what you want.<br>
<br>
If, instead of adding your observers to the render window interactor, you add them to the interactor's current style, you will see that the events are indeed invoked. But by default, the interactor style "eats" the left button up event such that the render window interactor never sees it. You can change this behavior by creating your own custom interactor style if you want to override it. (Or use one of the many other different types of interactor style available in VTK.)<br>
<br>
I added your code to this example...<br>
<br>
<a href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/Interaction/ObserverMemberFunction" target="_blank">http://www.vtk.org/Wiki/VTK/<u></u>Examples/Cxx/Interaction/<u></u>ObserverMemberFunction</a><br>
<br>
...and then put this code just before the call to "Start":<br>
<br>
...<br>
vtkInteractorObserver *currentStyle = renderWindowInteractor-><u></u>GetInteractorStyle();<br>
std::cout << "currentStyle class name: " << currentStyle->GetClassName() << std::endl;<br>
<br>
vtkInteractorStyleSwitch *iss = vtkInteractorStyleSwitch::<u></u>SafeDownCast(currentStyle);<br>
vtkInteractorObserver *actualStyle = iss->GetCurrentStyle();<br>
std::cout << "actualStyle class name: " << actualStyle->GetClassName() << std::endl;<div class="im"><br>
<br>
vtkSmartPointer<<u></u>CRRotateCallBack> crk = vtkSmartPointer<<u></u>CRRotateCallBack>::New();<br></div>
actualStyle->AddObserver(<u></u>vtkCommand::<u></u>LeftButtonPressEvent, crk, 10.0f);<br>
//actualStyle->AddObserver(<u></u>vtkCommand::MouseMoveEvent, crk, 10.0f);<br>
actualStyle->AddObserver(<u></u>vtkCommand::<u></u>LeftButtonReleaseEvent, crk, 10.0f);<br>
<br>
renderWindowInteractor->Start(<u></u>);<br>
...<br>
<br>
<br>
One more change: I changed the beginning of your Execute callback to expect a different type of caller object:<br>
<br>
vtkInteractorObserver *iobs = vtkInteractorObserver::<u></u>SafeDownCast(caller);<br>
if( !iobs )<br>
{<br>
return;<br>
}<br>
<br>
<br>
The output looks like this when I run it and click in the window:<br>
<br>
currentStyle class name: vtkInteractorStyleSwitch<br>
actualStyle class name: vtkInteractorStyleJoystickCame<u></u>ra<br>
LeftButtonPressEvent<br>
LeftButtonReleaseEvent<br>
<br>
<br>
HTH,<br>
David C.<div class="HOEnZb"><div class="h5"><br>
<br>
<br>
-----Original Message-----<br>
From: Mengda Wu <<a href="mailto:wumengda@gmail.com" target="_blank">wumengda@gmail.com</a>><br>
To: vtkusers <<a href="mailto:vtkusers@vtk.org" target="_blank">vtkusers@vtk.org</a>><br>
Cc: clinton <<a href="mailto:clinton@elemtech.com" target="_blank">clinton@elemtech.com</a>>; EvilMax <<a href="mailto:maxim.privalov@gmail.com" target="_blank">maxim.privalov@gmail.com</a>><br>
Sent: Sun, Dec 1, 2013 9:19 pm<br>
Subject: [vtkusers] Mouse button release event is still broken in VTK 6.0.0 !<br>
<br>
<br>
<br>
Hi all,<br>
<br>
<br>
I found this series is very relevant to my issue.<br>
<br>
<br>
<br>
I am also trying to catch the LeftButtonReleaseEvent event in VTK 6.0.0. I believe it is still broken. Basically, I added observers of LeftButtonPressEvent, MouseMoveEvent, and LeftButtonReleaseEvent to RenderWindowInteractor. Only LeftButtonPressEvent and MouseMoveEvent got tracked in the C++ callback function. No LeftButtonReleaseEvent was observed.<br>
<br>
<br>
What I did was:<br>
<br>
<br>
vtkSmartPointer<<u></u>CRRotateCallBack> crk = vtkSmartPointer<<u></u>CRRotateCallBack>::New();<br>
this->ui->view1-><u></u>GetInteractor()->AddObserver(<u></u>vtkCommand::LeftButtonPress<br>
Event, crk, 10.0f); this->ui->view1-><u></u>GetInteractor()->AddObserver(<u></u>vtkCommand::MouseMoveEvent,<br>
crk, 10.0f); this->ui->view1-><u></u>GetInteractor()->AddObserver(<u></u>vtkCommand::LeftButtonRelea<br>
seEvent, crk, 10.0f);<br>
<br>
class CRRotateCallBack : public vtkCommand<br>
{<br>
public:<br>
static CRRotateCallBack *New() {return new CRRotateCallBack;}<br>
<br>
virtual void Execute(vtkObject *caller, unsigned long eventId, void*)<br>
{<br>
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::<u></u>SafeDownCast(caller);<br>
if( !iren ) return;<br>
<br>
if( eventId == vtkCommand::<u></u>LeftButtonPressEvent )<br>
{<br>
std::cout << "LeftButtonPressEvent" << std::endl;<br>
}<br>
else if( eventId == vtkCommand::MouseMoveEvent )<br>
{<br>
std::cout << "MouseMoveEvent " << std::endl;<br>
}<br>
else if( eventId == vtkCommand::<u></u>LeftButtonReleaseEvent ) //for some reason, this left mouse release event never gets here<br>
{<br>
std::cout << "LeftButtonReleaseEvent " << std::endl;<br>
}<br>
}<br>
};<br>
<br>
<br>
Thanks,<br>
<br>
Mengda<br>
<br>
<br>
<br>
<br>
<br>
<br>
On Mon, Oct 31, 2011 at 4:25 PM, Sebastien Jourdain <<a href="mailto:sebastien.jourdain@kitware.com" target="_blank">sebastien.jourdain@kitware.<u></u>com</a>> wrote:<br>
<br>
Hi Max,<br>
<br>
I get that but when I was monitoring the event that was happening on a<br>
C++ observer, I've noticed the following order.<br>
<br>
LeftButtonPressEvent<br>
StartInteractionEvent<br>
ModifiedEvent<br>
EndInteractionEvent<br>
RenderEvent<br>
<br>
So despite the fact that ReleaseEvent is not properly propagated (even<br>
in the C++ layer), I was wondering if you could rely on the<br>
EndInteractionEvent while we fix this bug ? Because, this event seems<br>
to map at the release time...<br>
<br>
Does it make sense ?<br>
<br>
At lease let me know if this could fix your issue temporarily...<br>
<br>
Thanks,<br>
<br>
Seb<br>
<br>
PS: If I get more time, I will track down the reason why the<br>
ReleaseEvent get digested...<br>
<br>
<br>
<br>
On Mon, Oct 31, 2011 at 4:16 PM, EvilMax <<a href="mailto:maxim.privalov@gmail.com" target="_blank">maxim.privalov@gmail.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi, Sebastien!<br>
<br>
I need to implement dragging of an actors, so I really need to track <br>
</blockquote>
mouse<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
button release event.<br>
<br>
--<br>
View this message in context: <br>
</blockquote>
<a href="http://vtk.1045678.n5.nabble.com/Mouse-button-release-is-still-broken-in-5-8-0-tp4949887p4953458.html" target="_blank">http://vtk.1045678.n5.nabble.<u></u>com/Mouse-button-release-is-<u></u>still-broken-in-5-8-0-<u></u>tp4949887p4953458.html</a><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Sent from the VTK - Users mailing list archive at Nabble.com.<br>
______________________________<u></u>_________________<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>
</blockquote>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/<u></u>opensource/opensource.html</a><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Please keep messages on-topic and check the VTK FAQ at: <br>
</blockquote>
<a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_<u></u>FAQ</a><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/<u></u>listinfo/vtkusers</a><br>
<br>
</blockquote>
______________________________<u></u>_________________<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/<u></u>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_<u></u>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/<u></u>listinfo/vtkusers</a><br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
______________________________<u></u>_________________<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/<u></u>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_<u></u>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/<u></u>listinfo/vtkusers</a><br>
<br>
</div></div></blockquote></div><br></div>