MouseResult Pane::Button( IInputProvider* pprovider, const Point& point, int button, bool bCaptured, bool bInside, bool bDown ) { MouseResult mouseResult; TRef<Pane> pthis = this; if (m_ppaneCapture) { mouseResult = m_ppaneCapture->Button( pprovider, point - Point::Cast(m_ppaneCapture->m_offset), button, true, m_ppaneHit != NULL, bDown ); if (mouseResult.Test(MouseResultRelease())) { m_ppaneCapture = NULL; } } else if (m_ppaneHit) { mouseResult = m_ppaneHit->Button( pprovider, point - Point::Cast(m_ppaneHit->m_offset), button, false, true, bDown ); if (mouseResult.Test(MouseResultCapture())) { m_ppaneCapture = m_ppaneHit; } } return mouseResult; }
MouseResult Button(IInputProvider* pprovider, const Point& point, int button, bool bCaptured, bool bInside, bool bDown) { if (bDown) { if (0 == button) { if (m_bCanDrag) { // start a drag m_bDragging = true; m_pointLastDrag = point; GetWindow()->SetCursor(AWF_CURSOR_DRAG); Changed(); return MouseResultCapture(); } } } else { if (m_bDragging && 0 == button) { m_bDragging = false; if (!bInside) { GetWindow()->SetCursor(AWF_CURSOR_DEFAULT); } else { GetWindow()->SetCursor(AWF_CURSOR_DRAG); } Changed(); return MouseResultRelease(); } } Changed(); return MouseResult(); }
// mouse/draging MouseResult HitTest(IInputProvider* pprovider, const Point& point, bool bCaptured) { // KGJV fix: remove capture if map was changed while dragging MouseResult mr = m_pimageSectorBkgnd->HitTest(pprovider, point, bCaptured); if (bCaptured && !m_bDragging) // we were capturing mouse but we're not dragging anymore { // reset the mouse cursor // if can drag and inside image then set 'hand' cursor if (m_bCanDrag && mr.Test(MouseResultHit())) { GetWindow()->SetCursor(AWF_CURSOR_DRAG); } else // otherwise default cursor { GetWindow()->SetCursor(AWF_CURSOR_DEFAULT); } // release the mouse capture mr.Set(MouseResultRelease()); } return mr; }
MouseResult Pane::HitTest(IInputProvider* pprovider, const Point& point, bool bCaptured) { bool bInside = !m_bHidden && point.X() >= 0 && point.X() < (float)XSize() && point.Y() >= 0 && point.Y() < (float)YSize(); if (m_ppaneCapture) { ZAssert(bCaptured); // // Is the mouse over the captured pane? // MouseResult mouseResult = m_ppaneCapture->HitTest( pprovider, point - Point::Cast(m_ppaneCapture->m_offset), true ); if (mouseResult.Test(MouseResultHit())) { m_ppaneHit = m_ppaneCapture; } else { m_ppaneHit = NULL; } // // Release Capture? // if (mouseResult.Test(MouseResultRelease())) { RemoveCapture(); return mouseResult; } // // Call MouseMove // m_ppaneCapture->MouseMove( pprovider, point - Point::Cast(m_ppaneCapture->m_offset), true, m_ppaneHit != NULL ); } else { // // // Which image are we over? // Pane* ppaneHit = NULL; // !!! if (bInside || m_ppaneHit != NULL) { if (bInside) { TRef<Pane> ppane; for(ppane = m_pchild; ppane!= NULL; ppane = ppane->m_pnext) { MouseResult mouseResult = ppane->HitTest( pprovider, point - Point::Cast(ppane->m_offset), false ); if (mouseResult.Test(MouseResultHit())) { // !!! some of the mdl files violate this // ZAssert(ppaneHit == NULL); if (ppaneHit == NULL) { ppaneHit = ppane; } } } } // // Call MouseMove, MouseEnter, or MouseLeave // if (m_ppaneHit != ppaneHit) { if (m_ppaneHit) { m_ppaneHit->MouseLeave(pprovider); } m_ppaneHit = ppaneHit; if (m_ppaneHit) { m_ppaneHit->MouseEnter( pprovider, point - Point::Cast(m_ppaneHit->m_offset) ); } } else if (m_ppaneHit) { m_ppaneHit->MouseMove( pprovider, point - Point::Cast(m_ppaneHit->m_offset), false, true ); } } if (bInside) { return MouseResultHit(); } else { return MouseResult(); } }