比较充实的一天:GFx整合有进展
今天终于把BackSpace键删除不了Text
Input里面字符的问题给解决了,发现原因是没处理WM_KEYDOWN和WM_KEYUP
就是这几行,呵呵,这是GamebryoGFxApp里面的,拿过来用就好了
//
Pass windows key messages to GFx
case WM_KEYDOWN:
case WM_KEYUP:
{
GFxKey::Code eKeyCode = GFxKey::VoidSymbol;
WPARAM wCharCode = pkEventRecord -> wParam;
if (wCharCode >= ' A ' && wCharCode <= ' Z ' )
{
eKeyCode = (GFxKey::Code) ((wCharCode - ' A ' ) +
GFxKey::A);
}
else if (wCharCode >= VK_F1 && wCharCode <= VK_F15)
{
eKeyCode = (GFxKey::Code) ((wCharCode - VK_F1) +
GFxKey::F1);
}
else if (wCharCode >= ' 0 ' && wCharCode <= ' 9 ' )
{
eKeyCode = (GFxKey::Code) ((wCharCode - ' 0 ' ) +
GFxKey::Num0);
}
else if (wCharCode >= VK_NUMPAD0 && wCharCode <= VK_DIVIDE)
{
eKeyCode = (GFxKey::Code) ((wCharCode - VK_NUMPAD0) +
GFxKey::KP_0);
}
else
{
for ( int i = 0 ; KeyCodeMap[i].winKey != 0 ; i ++ )
{
if (wCharCode == (UInt)KeyCodeMap[i].winKey)
{
eKeyCode = KeyCodeMap[i].appKey;
break ;
}
}
}
unsigned char asciiCode = 0 ;
if (eKeyCode != GFxKey::VoidSymbol)
{
// get the ASCII code, if possible.
UINT uScanCode =
((UINT)pkEventRecord -> lParam >> 16 ) & 0xFF ;
BYTE ks[ 256 ];
WORD charCode;
// Get the current keyboard state
::GetKeyboardState(ks);
if (::ToAscii((UINT)wCharCode, uScanCode, ks, & charCode, 0 )
> 0 )
{
asciiCode = LOBYTE (charCode);
}
}
GFxEvent::EventType eEventType = GFxEvent::KeyUp;
if (pkEventRecord -> uiMsg == WM_KEYDOWN)
eEventType = GFxEvent::KeyDown;
// Send the key event into the Scaleform movie
GFxKeyEvent kEvent(eEventType, eKeyCode, asciiCode, 0 );
m_spGFxManager -> HandleInputEvent(kEvent);
case WM_KEYDOWN:
case WM_KEYUP:
{
GFxKey::Code eKeyCode = GFxKey::VoidSymbol;
WPARAM wCharCode = pkEventRecord -> wParam;
if (wCharCode >= ' A ' && wCharCode <= ' Z ' )
{
eKeyCode = (GFxKey::Code) ((wCharCode - ' A ' ) +
GFxKey::A);
}
else if (wCharCode >= VK_F1 && wCharCode <= VK_F15)
{
eKeyCode = (GFxKey::Code) ((wCharCode - VK_F1) +
GFxKey::F1);
}
else if (wCharCode >= ' 0 ' && wCharCode <= ' 9 ' )
{
eKeyCode = (GFxKey::Code) ((wCharCode - ' 0 ' ) +
GFxKey::Num0);
}
else if (wCharCode >= VK_NUMPAD0 && wCharCode <= VK_DIVIDE)
{
eKeyCode = (GFxKey::Code) ((wCharCode - VK_NUMPAD0) +
GFxKey::KP_0);
}
else
{
for ( int i = 0 ; KeyCodeMap[i].winKey != 0 ; i ++ )
{
if (wCharCode == (UInt)KeyCodeMap[i].winKey)
{
eKeyCode = KeyCodeMap[i].appKey;
break ;
}
}
}
unsigned char asciiCode = 0 ;
if (eKeyCode != GFxKey::VoidSymbol)
{
// get the ASCII code, if possible.
UINT uScanCode =
((UINT)pkEventRecord -> lParam >> 16 ) & 0xFF ;
BYTE ks[ 256 ];
WORD charCode;
// Get the current keyboard state
::GetKeyboardState(ks);
if (::ToAscii((UINT)wCharCode, uScanCode, ks, & charCode, 0 )
> 0 )
{
asciiCode = LOBYTE (charCode);
}
}
GFxEvent::EventType eEventType = GFxEvent::KeyUp;
if (pkEventRecord -> uiMsg == WM_KEYDOWN)
eEventType = GFxEvent::KeyDown;
// Send the key event into the Scaleform movie
GFxKeyEvent kEvent(eEventType, eKeyCode, asciiCode, 0 );
m_spGFxManager -> HandleInputEvent(kEvent);
KeyCodeMap
static
struct
{
WPARAM winKey;
GFxKey::Code appKey;
} KeyCodeMap[] =
{
{VK_BACK, GFxKey::Backspace},
{VK_TAB, GFxKey::Tab},
{VK_CLEAR, GFxKey::Clear},
{VK_RETURN, GFxKey::Return},
{VK_SHIFT, GFxKey::Shift},
{VK_CONTROL, GFxKey::Control},
{VK_MENU, GFxKey::Alt},
{VK_PAUSE, GFxKey::Pause},
{VK_CAPITAL, GFxKey::CapsLock},
{VK_ESCAPE, GFxKey::Escape},
{VK_SPACE, GFxKey::Space},
{VK_PRIOR, GFxKey::PageUp},
{VK_NEXT, GFxKey::PageDown},
{VK_END, GFxKey::End},
{VK_HOME, GFxKey::Home},
{VK_LEFT, GFxKey::Left},
{VK_UP, GFxKey::Up},
{VK_RIGHT, GFxKey::Right},
{VK_DOWN, GFxKey::Down},
{VK_INSERT, GFxKey::Insert},
{VK_DELETE, GFxKey::Delete},
{VK_HELP, GFxKey::Help},
{VK_NUMLOCK, GFxKey::NumLock},
{VK_SCROLL, GFxKey::ScrollLock},
{VK_OEM_1, GFxKey::Semicolon},
{VK_OEM_PLUS, GFxKey::Equal},
{VK_OEM_COMMA, GFxKey::Comma},
{VK_OEM_MINUS, GFxKey::Minus},
{VK_OEM_PERIOD,GFxKey::Period},
{VK_OEM_2, GFxKey::Slash},
{VK_OEM_3, GFxKey::Bar},
{VK_OEM_4, GFxKey::BracketLeft},
{VK_OEM_5, GFxKey::Backslash},
{VK_OEM_6, GFxKey::BracketRight},
{VK_OEM_7, GFxKey::Quote}
};
{
WPARAM winKey;
GFxKey::Code appKey;
} KeyCodeMap[] =
{
{VK_BACK, GFxKey::Backspace},
{VK_TAB, GFxKey::Tab},
{VK_CLEAR, GFxKey::Clear},
{VK_RETURN, GFxKey::Return},
{VK_SHIFT, GFxKey::Shift},
{VK_CONTROL, GFxKey::Control},
{VK_MENU, GFxKey::Alt},
{VK_PAUSE, GFxKey::Pause},
{VK_CAPITAL, GFxKey::CapsLock},
{VK_ESCAPE, GFxKey::Escape},
{VK_SPACE, GFxKey::Space},
{VK_PRIOR, GFxKey::PageUp},
{VK_NEXT, GFxKey::PageDown},
{VK_END, GFxKey::End},
{VK_HOME, GFxKey::Home},
{VK_LEFT, GFxKey::Left},
{VK_UP, GFxKey::Up},
{VK_RIGHT, GFxKey::Right},
{VK_DOWN, GFxKey::Down},
{VK_INSERT, GFxKey::Insert},
{VK_DELETE, GFxKey::Delete},
{VK_HELP, GFxKey::Help},
{VK_NUMLOCK, GFxKey::NumLock},
{VK_SCROLL, GFxKey::ScrollLock},
{VK_OEM_1, GFxKey::Semicolon},
{VK_OEM_PLUS, GFxKey::Equal},
{VK_OEM_COMMA, GFxKey::Comma},
{VK_OEM_MINUS, GFxKey::Minus},
{VK_OEM_PERIOD,GFxKey::Period},
{VK_OEM_2, GFxKey::Slash},
{VK_OEM_3, GFxKey::Bar},
{VK_OEM_4, GFxKey::BracketLeft},
{VK_OEM_5, GFxKey::Backslash},
{VK_OEM_6, GFxKey::BracketRight},
{VK_OEM_7, GFxKey::Quote}
};
就是这么个小问题,我好几天没解决了,一直盯着WM_CHAR看,就是没看出什么问题来,然后就以为是要在flash文件里做什么特殊设置呢,我靠!flash不熟悉真是痛苦!
我要继续我的痛苦旅程,不经历痛苦就体验不到真正的快乐啊!嘿嘿,问题解决了好爽!
目前整合GFx的工作指导方针如下,因为大的架构已经建立起来了,剩下的就是一些完善工作了:
逢山开路,遇水搭桥,不能追求一步到位,开始用GFx打通流程,在做的过程中逐步完善
下一个待解决的问题:
Q: 如何设置或判断flash里面某个component的focus?因为我要在密码输入框有focus的时候逐字符加密,防止被某些同学盗号……
A: 我要在c++中设置或判断,所以用 GFxMovieView::Invoke
Button_Login.Focus?
【2008-10-6】今天用Selection.getFocus()老返回null,没搞清楚原因;Selection.setFocus()倒是好用。类似这种问题太多了,值不值得花费这么多时间在这个东西上?还是研究如何用在场景里吧!这个跟Flash本身没啥关系,不用研究Flash里面的东西。