New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scroll viewport to end on first render #170
Comments
Scrolling requests made during an It seems to me that the right time to make an "initial" |
I'm trying to encapsulate this functionality into widget as much as possible, and this solution unfortunately leaks implementation details into app global event handling code.
The thing is, currently I need to start managing viewport state just before I start drawing it. Better solution, in my opinion, would be somehow passing initial scrolling request as a combinator to |
I don't know what you're doing in your application, of course, but presumably if you have multiple ways to "get to" this widget then there is already a place to put code like this, e.g.,
I can definitely appreciate the desire to avoid leaking details like this into the main event handler, but on the whole I don't think it's possible to avoid that forever with Brick since it requires you to slice your application up to separate drawing from event handling anyway. Still, this is one of the reasons why I suggested the approach that I did in #169; viewports are great when they're a perfect fit for what you need to do, and beyond that they can be tricky to use correctly. The performance issue alone is enough of a reason not to use viewports, and your desire to always render the log "at the bottom" is another case where using viewports to indirectly get the behavior you want can be awkward. |
Okay, maybe I'm still not completely grasping your idea of where using viewport is a good idea. Anyway, one more case, when I would want to issue scroll request during rendering, is the moment of launching app, i.e. when no event has arrived at all yet. |
For that, see |
I have the same issue. I'd like to keep using a viewport, and I'm not quite seeing how to apply your comments above. In hledger-ui I navigate from the accounts screen to an account's register screen here, using helpers scrollSelectionToMiddle has no effect the first time through, since it finds no viewport for the new screen's list, which has not been rendered yet. @jtdaugherty, if any obvious solution jumps out at you do let me know. |
I see it's easy to call the draw function from an event handler. I thought this might do the trick, but I think it's probably not forcing enough evaluation (and Widget doesn't have the right instances for deepseq): rsCenterAndContinue ui = do
traceShow (length $ rsDraw ui) $ -- force a render in case this is the first time, to ensure there's a viewport we can scroll
scrollSelectionToMiddle $ rsList $ aScreen ui
continue ui |
@simonmichael I'm not sure I understand the problem you're facing. Would you be willing to file a separate ticket with a bit more description of what you want to accomplish? (I'm find it hard to tell whether your problem is the same as the one in this ticket.) |
(Also, for posterity, calling your drawing function in the event handler will have no effect whatsoever on the drawn state of the screen.) |
I seem to have a following problem:
vScrollToEnd
.In other words, scroll requests get lost if they happen before widget is rendered for the first time.
Am I doing something wrong?
If not, is there some way to get the viewport scrolled to the bottom during the very first render?
Thank you.
The text was updated successfully, but these errors were encountered: