@@ -159,13 +159,19 @@ fn (cfg &ScrollbarCfg) mouse_move_locked(layout &Layout, mut e Event, mut w Wind
159159 && e.mouse_x < = (ly.shape.x + ly.shape.width + extend) {
160160 offset := offset_mouse_change_x (ly, e.mouse_dx, cfg.id_track, w)
161161 w.view_state.scroll_x[cfg.id_track] = offset
162+ if ly.shape.on_scroll != unsafe { nil } {
163+ ly.shape.on_scroll (ly, mut w)
164+ }
162165 }
163166 }
164167 else {
165168 if e.mouse_y > = (ly.shape.y - extend)
166169 && e.mouse_y < = (ly.shape.y + ly.shape.height + extend) {
167170 offset := offset_mouse_change_y (ly, e.mouse_dy, cfg.id_track, w)
168171 w.view_state.scroll_y[cfg.id_track] = offset
172+ if ly.shape.on_scroll != unsafe { nil } {
173+ ly.shape.on_scroll (ly, mut w)
174+ }
169175 }
170176 }
171177 }
@@ -323,6 +329,9 @@ fn offset_from_mouse_x(layout &Layout, mouse_x f32, id_scroll u32, mut w Window)
323329 percent = 1
324330 }
325331 w.view_state.scroll_x[id_scroll] = - percent * (total_width - sb.shape.width)
332+ if sb.shape.on_scroll != unsafe { nil } {
333+ sb.shape.on_scroll (sb, mut w)
334+ }
326335 }
327336}
328337
@@ -346,6 +355,9 @@ fn offset_from_mouse_y(layout &Layout, mouse_y f32, id_scroll u32, mut w Window)
346355 percent = 1
347356 }
348357 w.view_state.scroll_y[id_scroll] = - percent * (total_height - sb.shape.height)
358+ if sb.shape.on_scroll != unsafe { nil } {
359+ sb.shape.on_scroll (sb, mut w)
360+ }
349361 }
350362}
351363
@@ -365,6 +377,9 @@ fn scroll_horizontal(layout &Layout, delta f32, mut w Window) bool {
365377 max_offset := f32_min (0 , layout.shape.width - layout.shape.padding.width () - content_width (layout))
366378 offset_x := w.view_state.scroll_x[v_id] + delta * gui_theme.scroll_multiplier
367379 w.view_state.scroll_x[v_id] = f32_clamp (offset_x, max_offset, 0 )
380+ if layout.shape.on_scroll != unsafe { nil } {
381+ layout.shape.on_scroll (layout, mut w)
382+ }
368383 return true
369384 }
370385 return false
@@ -386,6 +401,9 @@ fn scroll_vertical(layout &Layout, delta f32, mut w Window) bool {
386401 max_offset := f32_min (0 , layout.shape.height - layout.shape.padding.height () - content_height (layout))
387402 offset_y := w.view_state.scroll_y[v_id] + delta * gui_theme.scroll_multiplier
388403 w.view_state.scroll_y[v_id] = f32_clamp (offset_y, max_offset, 0 )
404+ if layout.shape.on_scroll != unsafe { nil } {
405+ layout.shape.on_scroll (layout, mut w)
406+ }
389407 return true
390408 }
391409 return false
0 commit comments