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)
| 217 | // and the event is left unprocessed, so a higher level can consume the |
| 218 | // remainder. |
| 219 | func (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. |
| 258 | func (wb *WidgetBase) parentScrollFrame() *Frame { |
no test coverage detected