//---------------------------------------------------------------------------------------------------- bool EEQuad2D::UpdateObjectState() { // the mouse is within the rect // GetFinalRect should be optimized! if (EECollision(GetFinalRect(), EECore::s_EECore->GetMousePosition())) { // DOWN if (EECore::s_EECore->IsKeyDown(VK_LBUTTON)) { if (m_state == EE_OBJECT_OVER && s_focusedObject == nullptr && m_isFocusable) OnMouseClicked(EECore::s_EECore->GetMousePosition()); } // DOWN TO UP else if (m_state == EE_OBJECT_DOWN && s_focusedObject == this && m_isFocusable) { OnMouseTriggered(EECore::s_EECore->GetMousePosition()); } // OVER else { OnMouseOver(EECore::s_EECore->GetMousePosition()); } } else { if (s_focusedObject == this && !EECore::s_EECore->IsKeyDown(VK_LBUTTON)) s_focusedObject = nullptr; else if (s_focusedObject != this) OnMouseFree(EECore::s_EECore->GetMousePosition()); } return true; }
EVENT_RESULT CGUIControl::SendMouseEvent(const CPoint &point, const CMouseEvent &event) { CPoint childPoint(point); m_transform.InverseTransformPosition(childPoint.x, childPoint.y); if (!CanFocusFromPoint(childPoint)) return EVENT_RESULT_UNHANDLED; bool handled = OnMouseOver(childPoint); EVENT_RESULT ret = OnMouseEvent(childPoint, event); if (ret) return ret; return (handled && (event.m_id == ACTION_MOUSE_MOVE)) ? EVENT_RESULT_HANDLED : EVENT_RESULT_UNHANDLED; }
void CFlyout::PreviewWndProc(UINT uMessage, WPARAM wParam, LPARAM lParam) { switch (uMessage) { case WM_MOUSEMOVE: OnMouseOver(); break; case WM_MOUSELEAVE: m_fMouseOver = FALSE; break; } CWindow::PreviewWndProc(uMessage, wParam, lParam); }
void CViewSelWnd::OnClick(POINT point, WPARAM fwKeys, BOOL bLeft) { if (!bLeft) return; OnMouseOver(point, fwKeys); if (m_nOver != -1) { DEVICEUINOTIFY uin; uin.msg = DEVUINM_SELVIEW; uin.from = DEVUINFROM_SELWND; uin.selview.nView = m_nOver; m_pUI->Notify(uin); } ReleaseCapture(); Destroy(); }
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; } }
void AbstractObj::mouseOver() { emit OnMouseOver(); }
// Basic window proc. It simply forward interesting messages to the appropriate handlers (OnXXX). // If child class defines this function, it should pass unhandled messages to CFlexWnd. LRESULT CFlexWnd::WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_GETFLEXWND: { if ((LPVOID)lParam == NULL) break; GETFLEXWNDSTRUCT &gfws = *((FAR GETFLEXWNDSTRUCT *)(LPVOID)lParam); switch (gfws.cbSize) { case sizeof(GETFLEXWNDSTRUCT): gfws.bFlexWnd = TRUE; gfws.pFlexWnd = this; return 0; default: assert(0); break; } break; } case WM_CREATE: { LPCREATESTRUCT lpCreateStruct = (LPCREATESTRUCT)lParam; LRESULT lr = OnCreate(lpCreateStruct); if (lr != -1) OnInit(); return lr; } case WM_INITDIALOG: { BOOL b = OnInitDialog(); OnInit(); return b; } case WM_TIMER: OnTimer((UINT)wParam); return 0; case WM_ERASEBKGND: return OnEraseBkgnd((HDC)wParam); case WM_PAINT: { // Check the update rectangle. If we don't have it, exit immediately. if (typeid(*this) == typeid(CDeviceView) && !GetUpdateRect(m_hWnd, NULL, FALSE)) return 0; PAINTSTRUCT ps; HDC hDC = BeginPaint(hWnd, &ps); if (InRenderMode()) OnRender(TRUE); else DoOnPaint(hDC); EndPaint(hWnd, &ps); return 0; } case WM_COMMAND: { WORD wNotifyCode = HIWORD(wParam); WORD wID = LOWORD(wParam); HWND hWnd = (HWND)lParam; return OnCommand(wNotifyCode, wID, hWnd); } case WM_NOTIFY: return OnNotify(wParam, lParam); case WM_MOUSEMOVE: case WM_LBUTTONDOWN: case WM_RBUTTONDOWN: case WM_LBUTTONDBLCLK: case WM_MOUSEWHEEL: { POINT point = {int(LOWORD(lParam)), int(HIWORD(lParam))}; switch (msg) { case WM_MOUSEMOVE: OnMouseOver(point, wParam); break; case WM_LBUTTONDOWN: OnClick(point, wParam, TRUE); break; case WM_RBUTTONDOWN: OnClick(point, wParam, FALSE); break; case WM_LBUTTONDBLCLK: OnDoubleClick(point, wParam, TRUE); break; case WM_MOUSEWHEEL: { // Send wheel msg to the window beneath the cursor HWND hWnd = WindowFromPoint(point); CFlexWnd *pWnd = NULL; if (hWnd) { pWnd = GetFlexWnd(hWnd); if (pWnd) pWnd->OnWheel(point, wParam); else return DefWindowProc(hWnd, msg, wParam, lParam); } break; } } return 0; } case WM_DESTROY: OnDestroy(); m_privhWnd = NULL; return 0; } if (!m_bIsDialog) return DefWindowProc(hWnd, msg, wParam, lParam); else return 0; }