void CControl::OnTouchBegin( float x, float y ) { m_bTouchInRect = true; CWindowManager::GetInstance()->SetFocusControl( this ); m_bClick = true; if (!m_strPressAnimationName.empty()) { if ( nullptr == m_pPressAnimation ) { m_pPressAnimation = CreateNodeAnimation( m_strPressAnimationName ); BEATS_ASSERT( m_pPressAnimation ); m_pPressAnimation->GetEventDispatcher()->SubscribeEvent(eET_EVENT_NODE_ANIMATION_FINISHED, &CControl::PressAnimationFinishCallBack, this); } m_pPressAnimation->GetEventDispatcher()->SetEnable( m_bResponseClickEvent && m_bEnable ); m_pPressAnimation->SetPlayType( eNAPT_ONCE ); m_pPressAnimation->Play(); } else { if ( m_bResponseClickEvent && m_bEnable ) { OnClickBegin(); } } }
void Button::OnKey(Key key, MouseButtonFlags buttons, QualifierFlags qualifiers) { if (HasFocus() && (key == KEY_ENTER || key == KEY_KP_ENTER || key == KEY_SPACE)) { // Simulate LMB click OnClickBegin(IntVector2(), IntVector2(), MouseButton::MOUSEB_LEFT, 0, 0, nullptr); OnClickEnd(IntVector2(), IntVector2(), MouseButton::MOUSEB_LEFT, 0, 0, nullptr, nullptr); } }
void CControl::PressAnimationFinishCallBack( CBaseEvent* event ) { OnClickBegin(); }