Skip to content
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

Make Textbox focusable and trigger redraw in response to request_layout #537

Merged
merged 4 commits into from
Sep 16, 2024

Conversation

PoignardAzur
Copy link
Contributor

@PoignardAzur PoignardAzur commented Aug 24, 2024

Fixes #301.

Comment on lines +579 to +533
// TODO - We assume that a relayout will trigger a repaint
if self.root_state().needs_paint
|| self.root_state().needs_accessibility
|| self.root_state().needs_layout
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick comment on this: right now layout is implicitly triggered as part of the paint/accessibility pass: you want to paint something, therefore you lay it out first.

A side-effect of this is that previous to this change, calling request_layout wouldn't call a layout pass until some widget somewhere requested a paint pass. (Even though the layout pass automatically requests a paint pass.)

Once pass spec is complete, layout will run with all the other passes whenever anything happens, and this line will be removed.

Copy link
Member

@DJMcNab DJMcNab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not clear to me why this isn't marked as fixing #301
We also need to remove all of the other workarounds to that bug.

The other orthogonal change looks fine.

masonry/src/render_root.rs Show resolved Hide resolved
@PoignardAzur
Copy link
Contributor Author

We also need to remove all of the other workarounds to that bug.

Anything left besides the ones I just patched?

Copy link
Member

@DJMcNab DJMcNab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These code changes look good to me.

Is there an example where this can be tested? I don't think any other widget can yet be focused, and TextBox eats Tab

We could probably change the title to include a mention of the new layout behaviour. E.g. to:

Make `Textbox` focusable and redraw in response to `request_layout`

@PoignardAzur
Copy link
Contributor Author

PoignardAzur commented Aug 26, 2024

IIRC Textbox doesn't eat Tab. When I was testing this I just made an example with two textboxes. I guess I could push a similar one.

@DJMcNab
Copy link
Member

DJMcNab commented Aug 27, 2024

The two textbox case isn't working for me...

@PoignardAzur PoignardAzur changed the title Fix tab focus in Textbox widget Make Textbox focusable and trigger redraw in response to request_layout Aug 30, 2024
@PoignardAzur
Copy link
Contributor Author

I've pushed a few fixes for crashes I saw, and I pushed an example with two textboxes.

Tab switching works with that example for me. If it doesn't for you, that's something we'll have to investigate more in-depth.

@PoignardAzur
Copy link
Contributor Author

(Pinging Philipp since IIRC Daniel is on vacation.)

Copy link
Contributor

@Philipp-M Philipp-M left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

(I'm also vacationing, but sitting in a train right now...)

@DJMcNab
Copy link
Member

DJMcNab commented Sep 2, 2024

What behaviour do you expect me to be seeing when I press Tab in two_textboxes? I cannot see a cursor after pressing it at the moment, and typing doesn't work either.

@PoignardAzur
Copy link
Contributor Author

What behaviour do you expect me to be seeing when I press Tab in two_textboxes? I cannot see a cursor after pressing it at the moment, and typing doesn't work either.

For me the cursor doesn't appear in the second box, but typing does work. It weird that it doesn't for you.

We might need to do a live debugging session.

@PoignardAzur PoignardAzur force-pushed the fix_tab_focus branch 2 times, most recently from 99dc016 to 362bb58 Compare September 12, 2024 12:14
@mwcampbell
Copy link
Contributor

There's some overlap between this branch and the work I just did on my textbox-accesskit-focus branch (before I discovered this branch). You may want to look at what I did on that branch, particularly with the new TextWithSelection::focus_gained method, for a resolution to the remaining erratic behavior with tabbing and textboxes.

@PoignardAzur
Copy link
Contributor Author

Will do.

@mwcampbell
Copy link
Contributor

Is this supposed to work yet when pressing Tab to focus the first (or only) textbox if nothing has focus yet? That doesn't work for me when running the to_do_mvc example from the latest commit on this branch.

Merged via the queue into main with commit 09d9ad5 Sep 16, 2024
17 checks passed
@PoignardAzur PoignardAzur deleted the fix_tab_focus branch September 16, 2024 15:38
@PoignardAzur
Copy link
Contributor Author

No, I fixed that in #593.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Masonry: Request layout does not implicitly start a redraw
4 participants