mirror of https://github.com/minetest/minetest.git
Don't send unnecessary events
This commit is contained in:
parent
23b0bf155a
commit
753008a547
|
@ -75,13 +75,6 @@ bool GUIScrollBar::OnEvent(const SEvent &event)
|
|||
setPosInterpolated(getTargetPos() - small_step);
|
||||
else if (event.GUIEvent.Caller == down_button)
|
||||
setPosInterpolated(getTargetPos() + small_step);
|
||||
|
||||
SEvent e;
|
||||
e.EventType = EET_GUI_EVENT;
|
||||
e.GUIEvent.Caller = this;
|
||||
e.GUIEvent.Element = nullptr;
|
||||
e.GUIEvent.EventType = EGET_SCROLL_BAR_CHANGED;
|
||||
Parent->OnEvent(e);
|
||||
return true;
|
||||
} else if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUS_LOST)
|
||||
if (event.GUIEvent.Caller == this)
|
||||
|
@ -96,13 +89,6 @@ bool GUIScrollBar::OnEvent(const SEvent &event)
|
|||
s8 d = event.MouseInput.Wheel < 0 ? -1 : 1;
|
||||
s8 h = is_horizontal ? 1 : -1;
|
||||
setPosInterpolated(getTargetPos() + (d * small_step * h));
|
||||
|
||||
SEvent e;
|
||||
e.EventType = EET_GUI_EVENT;
|
||||
e.GUIEvent.Caller = this;
|
||||
e.GUIEvent.Element = nullptr;
|
||||
e.GUIEvent.EventType = EGET_SCROLL_BAR_CHANGED;
|
||||
Parent->OnEvent(e);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -51,10 +51,12 @@ public:
|
|||
void setSmallStep(const s32 &step);
|
||||
void setLargeStep(const s32 &step);
|
||||
//! Sets a position immediately, aborting any ongoing interpolation.
|
||||
// setPos does not send EGET_SCROLL_BAR_CHANGED events for you.
|
||||
void setPos(const s32 &pos);
|
||||
//! Sets a target position for interpolation.
|
||||
// If you want to do an interpolated addition, use
|
||||
// setPosInterpolated(getTargetPos() + x).
|
||||
// setPosInterpolated takes care of sending EGET_SCROLL_BAR_CHANGED events.
|
||||
void setPosInterpolated(const s32 &pos);
|
||||
void setPageSize(const s32 &size);
|
||||
void setArrowsVisible(ArrowVisibility visible);
|
||||
|
|
Loading…
Reference in New Issue