// ----------------------------------------------------------------------- // // // ROUTINE: CLTWnd::OnMouseMove // // PURPOSE: This is the actual mouse move handler // // ----------------------------------------------------------------------- // BOOL CLTWnd::OnMouseMove(int xPos, int yPos) { // Update the cursor's position on us m_xCursor = xPos - GetWindowLeft(); m_yCursor = yPos - GetWindowTop(); // Handle draggage if necessary if(s_pWndCapture == this) { if(IsFlagSet(LTWF_DRAGGABLE)) { OnDrag(xPos,yPos); } else if(IsFlagSet(LTWF_PARENTDRAG)) { // Drag our parent // Find our parent CLTWnd* pWnd = this; CLTWnd* pParent = m_pParentWnd; while(pWnd->IsFlagSet(LTWF_FIXEDCHILD) && pParent) { pWnd = pParent; pParent = pWnd->GetParent(); } pWnd->OnDrag(xPos,yPos); } } return(this != s_pMainWnd); }
bool UKUISliderWidget::OnMouseButtonDown( const FKUIInterfaceContainerMouseButtonEvent& stEventInfo ) { if ( !CanReceieveMouseEvents() ) return Super::OnMouseButtonDown( stEventInfo ); if ( stEventInfo.eButton != EMouseButtons::Left ) return Super::OnMouseButtonDown( stEventInfo ); if ( !IsVisibleRecursive() ) return Super::OnMouseButtonDown( stEventInfo ); if ( IsDisabledRecursive() ) return Super::OnMouseButtonDown( stEventInfo ); if ( !IsMouseOver() ) return Super::OnMouseButtonDown( stEventInfo ); if ( oHandle.IsValid() && oHandle->IsMouseOver() ) { if ( bHorizontal ) fMouseDownOffset = stEventInfo.v2Location.X - oHandle->GetScreenLocation().X - oHandle->GetSize().X / 2.f; else fMouseDownOffset = stEventInfo.v2Location.Y - oHandle->GetScreenLocation().Y - oHandle->GetSize().Y / 2.f; } else fMouseDownOffset = 0.f; bDragging = true; OnDrag( bHorizontal ? stEventInfo.v2Location.X : stEventInfo.v2Location.Y ); KUISendSubEvent( FKUIInterfaceEvent, EKUIInterfaceWidgetEventList::E_StateChange ); return true; }
void UKUISliderWidget::OnMouseMove( const FKUIInterfaceContainerMouseLocationEvent& stEventInfo ) { Super::OnMouseMove( stEventInfo ); if ( !CanReceieveMouseEvents() ) return; if ( !bDragging ) return; if ( IsDisabledRecursive() ) return; OnDrag( bHorizontal ? stEventInfo.v2NewLocation.X : stEventInfo.v2NewLocation.Y ); }
void CModifiedButtonWidget::OnMouseEvent( CMouseEvent* event ) { // logger << event->GetButtons() << std::endl; switch( event->GetType() ) { case types::mouse_button_down: if( event->GetButtons() & myClickableButtons ) { mySpriteHandler->PlayAnimation( GetSprite(), "mouse_button_down" ); myClicked = true; OnMouseDown( myParam ); } if( myDragable && event->GetButtons() & myDragableButtons ) { // mySpriteHandler->PlayAnimation( GetSprite(), "mouse_on_drag" ); myDragging = true; myDragOffset = types::point( this->GetRect().x, this->GetRect().y ) - event->GetPosition(); IMouse::AddConstantEventListeners( this ); } if( myDoubleClickable && event->GetButtons() & myDoubleClickableButtons && myDoubleClicking == true ) { if( myDoubleClickTimer.GetTime() < double_click_time ) OnDoubleClick( myParam ); myDoubleClicking = false; } else if( myDoubleClickable && event->GetButtons() & myDoubleClickableButtons && myDoubleClicking == false ) { myDoubleClickTimer.Reset(); myDoubleClickTimer.Resume(); myDoubleClicking = true; } else if ( myDoubleClickable && event->GetButtons() & !myDoubleClickableButtons ) { myDoubleClicking = false; } break; case types::mouse_button_up: if( myClicked && event->GetButtons() & myClickableButtons ) { mySpriteHandler->PlayAnimation( GetSprite(), "mouse_button_up" ); OnClick( myParam ); myClicked = false; OnMouseUp( myParam ); } if( myDragable && event->GetButtons() & myDragableButtons ) { // mySpriteHandler->PlayAnimation( GetSprite(), "mouse_on_drag" ); myDragging = false; IMouse::RemoveConstantEventListeners( this ); OnDragEnd(); } myClicked = false; break; case types::mouse_move: if( myDragging ) { types::point where_to = event->GetPosition() + myDragOffset; // Fixed 12-09-2007 by Pete //-------------------------------------------------------------------------- // BUGBUG: This should be the commented line, but the signal-slot // doesn't support three parameters at the current time // OnDrag( where_to.x - GetRect().x, where_to.y - GetRect().y, myParam ); if( config::automatic_dragging ) MoveBy( types::point( where_to.x - GetRect().x, where_to.y - GetRect().y ) ); OnDrag( where_to.x - GetRect().x, where_to.y - GetRect().y, myParam ); } // myDoubleClicking = false; break; case types::mouse_over: { const std::string animation = mySelectionOn?"select_mouse_over":"mouse_over"; mySpriteHandler->PlayAnimation( GetSprite(), animation ); OnMouseOver( myParam ); } break; case types::mouse_out: { const std::string animation = mySelectionOn?"select_mouse_out":"mouse_out"; mySpriteHandler->PlayAnimation( GetSprite(), animation ); myClicked = false; myDoubleClicking = false; OnMouseOut( myParam ); } break; default: break; } }