From 783146dabc6a8b0d661580206dcb5e6668b3d216 Mon Sep 17 00:00:00 2001 From: Dustin Swan Date: Fri, 13 Feb 2026 17:37:03 -0700 Subject: [PATCH] we have mouse scrolling --- src/cg/05-palette.cg | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/cg/05-palette.cg b/src/cg/05-palette.cg index e43c008..55af6e1 100644 --- a/src/cg/05-palette.cg +++ b/src/cg/05-palette.cg @@ -16,6 +16,7 @@ palette = config \ dialogPadding = 0; + itemGap = 1; textInputHeight = 40; sectionHeight = 30; contentWidth = windowWidth - (dialogPadding * 2); @@ -34,8 +35,12 @@ palette = config \ | Item _ \ textInputHeight | _ \ 0; + totalHeight = (sum (map itemHeight results)) + itemGap * (len results - 1); + itemY = i \ (sum (map itemHeight (take i results))) + i; + onScroll = delta \ paletteState.scrollOffset := max 0 (min (totalHeight - listHeight) (paletteState.scrollOffset + delta.deltaY)); + scrollTo = index \ y = itemY index; h = unwrapOr 0 (nth index (map itemHeight results)); @@ -114,9 +119,9 @@ palette = config \ h = listHeight, scrollX = 0, scrollY = paletteState.scrollOffset, - onScroll = _ \ noOp, + onScroll = onScroll, child = ui.column { - gap = 1, + gap = itemGap, children = [ ...(mapWithIndex (entry i \ entry | Section title \ box {