void VScrollBarOverlayWindow::SetThumbOffsetY(int y) { int const new_offset = GetValidOffsetYValue(y); if (new_offset != mouse_offset_y_) { if (HasState(ThumbState::MOUSE_DOWN)) MouseDragging(); mouse_offset_y_ = new_offset; QueueDraw(); } }
void wxMouseEventsManager::OnMove(wxMouseEvent& event) { switch ( m_state ) { case State_Normal: event.Skip(); break; case State_Pressed: wxASSERT_MSG( event.LeftIsDown(), "should have detected mouse being released" ); { // it's probably a bad idea to query the system for these // values every time the mouse is moved so cache them on the // assumption that they don't change -- which is wrong, of // course, the user can change them but it doesn't happen often static const int dragMinX = wxSystemSettings::GetMetric(wxSYS_DRAG_X); static const int dragMinY = wxSystemSettings::GetMetric(wxSYS_DRAG_Y); const wxPoint& pos = event.GetPosition(); const wxPoint ofs = pos - m_posLast; if ( abs(ofs.x) > dragMinX || abs(ofs.y) > dragMinY ) { // the mouse left the rectangle inside which its movements // are considered to be too small to constitute a start of // drag operation, do [attempt to] start it now if ( MouseDragBegin(m_item, pos) ) { m_state = State_Dragging; } } else // still didn't move far enough away { event.Skip(); } } break; case State_Dragging: m_posLast = event.GetPosition(); MouseDragging(m_item, m_posLast); break; } }