scroll wheel on spinners
use crate::{
- text, Btn, Button, EventCtx, GeomBatch, GfxCtx, Line, ScreenDims, ScreenPt, Text, Widget,
- WidgetImpl, WidgetOutput,
+ text, Btn, Button, EventCtx, GeomBatch, GfxCtx, Line, ScreenDims, ScreenPt, ScreenRectangle,
+ Text, Widget, WidgetImpl, WidgetOutput,
};
use geom::{Polygon, Pt2D};
@@ -84,6 +84,19 @@ impl WidgetImpl for Spinner {
}
ctx.no_op_event(true, |ctx| self.down.event(ctx, output));
}
+
+ if let Some(pt) = ctx.canvas.get_cursor_in_screen_space() {
+ if ScreenRectangle::top_left(self.top_left, self.dims).contains(pt) {
+ if let Some((_, dy)) = ctx.input.get_mouse_scroll() {
+ if dy > 0.0 && self.current != self.high {
+ self.current += 1;
+ }
+ if dy < 0.0 && self.current != self.low {
+ self.current -= 1;
+ }
+ }
+ }
+ }
}
fn draw(&self, g: &mut GfxCtx) {
