@@ -151,14 +151,15 @@ int CustomListViewPanel::HeightToCell(int which) const
151151
152152void CustomListViewPanel::OnLeftDownMouseEvent (wxMouseEvent& event)
153153{
154- m_firstPress = m_lastLocation = event.GetPosition ();
155- // printf("Mouse down @(%d, %d)\n", event.GetPosition().x, event.GetPosition().y);
154+ m_firstPress = m_lastLocation = CalcUnscrolledPosition (event.GetPosition ());
155+ wxClientDC dc{ this };
156+
156157 // which cell would this be?
157- auto which_cell = WhichCell (event. GetPosition () );
158+ auto which_cell = WhichCell (m_firstPress );
158159 m_selected = which_cell;
159160 m_dragging = true ;
160161 if (which_cell < mCells .size ()) {
161- auto mouse_click = event. GetPosition () ;
162+ auto mouse_click = m_firstPress ;
162163 mouse_click.y -= HeightToCell (which_cell);
163164 mCells .at (which_cell)->OnClick (mouse_click);
164165 }
@@ -167,9 +168,8 @@ void CustomListViewPanel::OnLeftDownMouseEvent(wxMouseEvent& event)
167168
168169void CustomListViewPanel::OnLeftDoubleClick (wxMouseEvent& event)
169170{
170- // printf("Mouse down @(%d, %d)\n", event.GetPosition().x, event.GetPosition().y);
171171 // which cell would this be?
172- auto which_cell = WhichCell (event.GetPosition ());
172+ auto which_cell = WhichCell (CalcUnscrolledPosition ( event.GetPosition () ));
173173 if (which_cell < mCells .size ()) {
174174 OnEditEntry (which_cell);
175175 }
@@ -180,9 +180,8 @@ void CustomListViewPanel::OnLeftUpMouseEvent(wxMouseEvent& event)
180180{
181181 auto starting_cell = WhichCell (m_firstPress);
182182 m_lastLocation = m_firstPress;
183- // printf("Mouse up @(%d, %d)\n", event.GetPosition().x, event.GetPosition().y);
184183 // which cell would this be?
185- auto which_cell = WhichCell (event.GetPosition ());
184+ auto which_cell = WhichCell (CalcUnscrolledPosition ( event.GetPosition () ));
186185 if (starting_cell != which_cell) {
187186 // reorder.
188187 OnMoveEntry (starting_cell, which_cell);
@@ -196,7 +195,7 @@ void CustomListViewPanel::OnLeftUpMouseEvent(wxMouseEvent& event)
196195void CustomListViewPanel::OnMouseMove (wxMouseEvent& event)
197196{
198197 if (event.LeftIsDown () && event.GetPosition ().y >= 0 ) {
199- m_lastLocation = event.GetPosition ();
198+ m_lastLocation = CalcUnscrolledPosition ( event.GetPosition () );
200199 }
201200 Refresh ();
202201}
0 commit comments