dy=s.scroll-menuScrollMax-8;// Makes it so the last 'page' has the same position as previous pages. This should be done dynamically (change the static 8 to be a variable) so the offset is correct even when no widget field or title field is present.
if(s.scroll-dy<menuScrollMin)
dy=s.scroll-menuScrollMin;
s.scroll-=dy;
varoldScroll=rScroll;
rScroll=s.scroll&~1;
dy=oldScroll-rScroll;
if(!dy||options.c<=3)return;//options.c<=3 should maybe be dynamic, so 3 would be replaced by a variable dependent on R=Bangle.appRect. It's here so we don't try to scroll if all entries fit in the app rectangle.
//print(i, options.c, options.c-i); //debugging info
while(y<R.y2-(options.h*((options.c-i)<=0))){//- (options.h*((options.c-i)<=0)) makes sure we don't go beyond the menu entries in the menu object "options". This has to do with "dy = s.scroll - menuScrollMax-8" above.
options.draw(i,{x:R.x,y:y,w:R.w,h:options.h});
i++;
y+=options.h;
}
}else{// d>0
g.setClipRect(R.x,R.y,R.x2,R.y+d);
leti=YtoIdx(R.y+d);
lety=idxToY(i);
//print(i, options.c, options.c-i); //debugging info