|
楼主 |
发表于 2012-10-15 13:33:16
|
显示全部楼层
已经完全搞定了,因为是用的C#调用OSG+MYGUI
具体步骤:
1.在C#窗体内添加中文输入法切换- virtual System::Void WndProc(Message% m) override
- {
- if(m.Msg==WM_IME_SETCONTEXT && m.WParam.ToInt32() == 1)
- ImmAssociateContext((HWND)Handle.ToInt32(),_hIMC);
- if(m.Msg==WM_CHAR && m.LParam.ToInt32() == 1)
- {
- test(m.WParam.ToInt32());
- }
- System::Windows::Forms::Form::WndProc(m);
- }
复制代码 2.test方法- void MainForm::test(int w)
- {
- osg::ref_ptr<UserData> obj = new UserData;
- obj->setData(w);
- double eventTime = _viewer->getEventQueue()->getTime();
- _viewer->getEventQueue()->userEvent(obj.get(),eventTime);
- }
复制代码 3.MYGUIManager里面添加- case osgGA::GUIEventAdapter::USER:
- {
- UserData* userDate= (UserData*)(ea.getUserData());
- if(userDate->getStatus()==SHH3D::UserData::Status::ImmInfo)
- _bHanlded = MyGUI::InputManager::getInstance().injectKeyPress(MyGUI::KeyCode::None ,(MyGUI::Char)(userDate->getData()));
- break;
- }
复制代码
PS:如果不是C#窗体调用,因为可以切换输入法,所以可直接添加 case WM_IME_CHAR : |
|