[vtkusers] OnKeyRelease
Andrew Dolgert
ajd27 at cornell.edu
Tue Jun 1 17:13:35 EDT 2004
Hi Matt,
Windows has fires two events for a key down: WM_KEYDOWN, and then WM_CHAR
or WM_UNICHAR. It then fires WM_KEYUP when the key is released. The VTK
interactor turns a KEYDOWN into a KeyPress event, KEYUP into a KeyRelease
event, and WM_CHAR into a CharEvent.
I turned on debugging for the interactor, and it shows that, during a
WM_KEYUP event, something queries the interactor for the value of the key (I
was releasing 'b'). It seems to me that the key release worked.
If you are using .NET, then you are sending events to VTK by hand. I found
some code of mine where, for some unknown reason, I didn't send every event
to VTK. I used a case statement instead, and it would be easy to miss the
WM_KEYUP event in that case statement. Did you do this and forget to
include WM_KEYUP? See the code below.
I can't be the only one who made a pure managed C++
Windows::Forms::UserControl in order to use VTK from C#. We should just
have an example.
- Drew
void FEMViewControl::DefWndProc( System::Windows::Forms::Message* msg)
{
int msgType = msg->get_Msg();
switch ( msgType ) {
case WM_CHAR:
System::Diagnostics::Debug::WriteLine("char");
break;
case WM_KEYDOWN:
System::Diagnostics::Debug::WriteLine("key down");
break;
case WM_KEYUP:
System::Diagnostics::Debug::WriteLine("key up");
break;
}
switch ( msgType ) {
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:
case WM_MBUTTONDOWN:
case WM_MBUTTONUP:
case WM_RBUTTONDOWN:
case WM_RBUTTONUP:
case WM_MOUSEMOVE:
case WM_CHAR:
case WM_KEYDOWN:
case WM_KEYUP:
case WM_TIMER:
int lresult = 0;
if ( 0 != m_interactor->GetInitialized() )
{
lResult = ::vtkHandleMessage2(
(HWND) msg->get_HWnd().ToPointer(),
msg->get_Msg(),
(WPARAM) msg->get_WParam().ToPointer(),
(LPARAM) msg->get_LParam().ToPointer(),
m_interactor );
}
}
__super::DefWndProc( msg );
}
More information about the vtkusers
mailing list