mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-22 16:21:24 -06:00
FIX: handle mouseCaptureLost in common ctrls
Change-Id: Ifde2406911a628fa61acf41c0e7a5120612d73bf
This commit is contained in:
parent
e2d10baea0
commit
3d7d2badf7
6 changed files with 42 additions and 3 deletions
|
@ -8,6 +8,7 @@ BEGIN_EVENT_TABLE(StepCtrl, StepCtrlBase)
|
|||
EVT_LEFT_DOWN(StepCtrl::mouseDown)
|
||||
EVT_MOTION(StepCtrl::mouseMove)
|
||||
EVT_LEFT_UP(StepCtrl::mouseUp)
|
||||
EVT_MOUSE_CAPTURE_LOST(StepCtrl::mouseCaptureLost)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
StepCtrlBase::StepCtrlBase(wxWindow * parent,
|
||||
|
@ -133,6 +134,7 @@ void StepCtrl::mouseDown(wxMouseEvent &event)
|
|||
if (rcThumb.Contains(pt)) {
|
||||
pos_thumb = wxPoint{circleX, size.y / 2};
|
||||
drag_offset = pos_thumb - pt;
|
||||
CaptureMouse();
|
||||
} else if (rcBar.Contains(pt)) {
|
||||
if (pt.x < circleX) {
|
||||
if (step > 0) SelectItem(step - 1);
|
||||
|
@ -151,6 +153,10 @@ void StepCtrl::mouseMove(wxMouseEvent &event)
|
|||
wxSize size = GetSize();
|
||||
int itemWidth = size.x / steps.size();
|
||||
int index = pos_thumb.x / itemWidth;
|
||||
if (index < 0)
|
||||
index = 0;
|
||||
else if (index >= steps.size())
|
||||
index = steps.size() - 1;
|
||||
if (index != pos_thumb.y) {
|
||||
pos_thumb.y = index;
|
||||
Refresh();
|
||||
|
@ -163,8 +169,20 @@ void StepCtrl::mouseUp(wxMouseEvent &event)
|
|||
wxSize size = GetSize();
|
||||
int itemWidth = size.x / steps.size();
|
||||
int index = pos_thumb.x / itemWidth;
|
||||
pos_thumb = {0, 0};
|
||||
SelectItem(index < steps.size() ? index : steps.size() - 1);
|
||||
if (index < 0)
|
||||
index = 0;
|
||||
else if (index >= steps.size())
|
||||
index = steps.size() - 1;
|
||||
pos_thumb = {0, 0};
|
||||
SelectItem(index);
|
||||
if (HasCapture())
|
||||
ReleaseMouse();
|
||||
}
|
||||
|
||||
void StepCtrl::mouseCaptureLost(wxMouseCaptureLostEvent &event)
|
||||
{
|
||||
wxMouseEvent evt;
|
||||
mouseUp(evt);
|
||||
}
|
||||
|
||||
void StepCtrl::doRender(wxDC &dc)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue