MCPcopy Create free account
hub / github.com/cogentcore/core / scrollDelta

Method scrollDelta

core/scroll.go:219–255  ·  view source on GitHub ↗

scrollDelta processes a scroll event. If only one dimension is processed, and there is a non-zero in other, then the consumed dimension is reset to 0 and the event is left unprocessed, so a higher level can consume the remainder.

(e events.Event)

Source from the content-addressed store, hash-verified

217// and the event is left unprocessed, so a higher level can consume the
218// remainder.
219func (fr *Frame) scrollDelta(e events.Event) {
220 se := e.(*events.MouseScroll)
221 fdel := se.Delta
222
223 hasShift := e.HasAnyModifier(key.Shift, key.Alt) // shift or alt indicates to scroll horizontally
224 if hasShift {
225 if !fr.HasScroll[math32.X] { // if we have shift, we can only horizontal scroll
226 return
227 }
228 if fr.scrollActionDelta(math32.X, fdel.Y) {
229 e.SetHandled()
230 }
231 return
232 }
233
234 if fr.HasScroll[math32.Y] && fr.HasScroll[math32.X] {
235 ch1 := fr.scrollActionDelta(math32.Y, fdel.Y)
236 ch2 := fr.scrollActionDelta(math32.X, fdel.X)
237 if ch1 || ch2 {
238 e.SetHandled()
239 }
240 } else if fr.HasScroll[math32.Y] {
241 if fr.scrollActionDelta(math32.Y, fdel.Y) {
242 e.SetHandled()
243 }
244 } else if fr.HasScroll[math32.X] {
245 if se.Delta.X != 0 {
246 if fr.scrollActionDelta(math32.X, fdel.X) {
247 e.SetHandled()
248 }
249 } else if se.Delta.Y != 0 {
250 if fr.scrollActionDelta(math32.X, fdel.Y) {
251 e.SetHandled()
252 }
253 }
254 }
255}
256
257// parentScrollFrame returns the first parent frame that has active scrollbars.
258func (wb *WidgetBase) parentScrollFrame() *Frame {

Callers 1

InitMethod · 0.95

Calls 3

scrollActionDeltaMethod · 0.95
HasAnyModifierMethod · 0.65
SetHandledMethod · 0.65

Tested by

no test coverage detected