void OUGUIObject::SetMouseLButton(bool bDown) { if(bDown == m_bMouseLButton) return; m_bMouseLButton = bDown; if(m_bMouseLButton) { /** 设置控件 */ if(!IsChild(OUGUIObject::GetFocusControl())) { OUGUIObject::SetFocusControl(this); } /** 激活控件 (如拖曳) */ if(!IsChild(OUGUIObject::GetActiveControl())) { OUGUIObject::SetActiveControl(this); } OnMouseLButtonDown(); } else { if(OUGUIObject::GetActiveControl() == this) { OUGUIObject::SetActiveControl(NULL); } OnMouseLButtonUp(); } }
bool Desktop::OnEvent(const SEvent& event) { bool bResult = false; switch ( event.EventType ) { case EET_MOUSE_INPUT_EVENT: { switch ( event.MouseInput.Event ) { case EMIE_LMOUSE_PRESSED_DOWN: { bResult = OnMouseLButtonDown(event.MouseInput); } break; case EMIE_MOUSE_MOVED: { bResult = OnMouseMoved(event.MouseInput); } break; } } break; case EET_GUI_EVENT: { switch ( event.GUIEvent.EventType ) { case EGET_ELEMENT_FOCUSED: { bResult = OnGUIElementFocused(event.GUIEvent); } break; case EGET_ELEMENT_CLOSED: { bResult = OnGUIElementClosed(event.GUIEvent); } break; case EGET_MENU_ITEM_SELECTED: { bResult = OnGUIMenuItemSelected(event.GUIEvent); } break; default: break; } } } return bResult; }