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

Method ScrollToBox

core/scroll.go:386–400  ·  view source on GitHub ↗

ScrollToBox scrolls the layout to ensure that given rect box is in view. Returns true if scrolling was needed

(box image.Rectangle)

Source from the content-addressed store, hash-verified

384// ScrollToBox scrolls the layout to ensure that given rect box is in view.
385// Returns true if scrolling was needed
386func (fr *Frame) ScrollToBox(box image.Rectangle) bool {
387 did := false
388 if fr.HasScroll[math32.Y] && fr.HasScroll[math32.X] {
389 did = fr.scrollToBoxDim(math32.Y, box.Min.Y, box.Max.Y)
390 did = did || fr.scrollToBoxDim(math32.X, box.Min.X, box.Max.X)
391 } else if fr.HasScroll[math32.Y] {
392 did = fr.scrollToBoxDim(math32.Y, box.Min.Y, box.Max.Y)
393 } else if fr.HasScroll[math32.X] {
394 did = fr.scrollToBoxDim(math32.X, box.Min.X, box.Max.X)
395 }
396 if did {
397 fr.NeedsRender()
398 }
399 return did
400}
401
402// ScrollDimToStart scrolls to put the given child coordinate position (eg.,
403// top / left of a view box) at the start (top / left) of our scroll area, to

Callers 2

scrollToWidgetMethod · 0.95
scrollInViewMethod · 0.80

Calls 2

scrollToBoxDimMethod · 0.95
NeedsRenderMethod · 0.80

Tested by

no test coverage detected