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

Hyperlink: resize underline and focus rectangles to text width; ignore tap outside of text area #4320

Merged
merged 9 commits into from
Jan 5, 2024

Conversation

dweymouth
Copy link
Contributor

@dweymouth dweymouth commented Oct 15, 2023

Description:

Constrain the focus rectangle, underline, and tappable area to the part of the hyperlink widget that is actually displaying text, if the widget itself is sized larger than the text display area.

Fixes #3528

Checklist:

  • Tests included.
  • Lint and formatter run with no errors.
  • Tests all pass.

Where applicable:

@dweymouth dweymouth marked this pull request as draft October 15, 2023 20:35
@dweymouth dweymouth marked this pull request as ready for review October 16, 2023 16:53
@dweymouth dweymouth requested a review from andydotxyz October 16, 2023 17:18
@andydotxyz
Copy link
Member

I think there are new test failures (window tests on the ubuntu CI) is it possible the hyperlink is used in them and this change is impacting the outcomes?

@dweymouth
Copy link
Contributor Author

I think there are new test failures (window tests on the ubuntu CI) is it possible the hyperlink is used in them and this change is impacting the outcomes?

That is certainly possible and looking further at the test log I think that is the case. I'll try to resolve this later in the evening.

@dweymouth
Copy link
Contributor Author

dweymouth commented Oct 19, 2023

It seems like this has uncovered a platform difference between Ubuntu and the other desktop OSes - I can see from adding debug logs that MouseIn is being called on the Hyperlink widget, which then sets the hovered flag to true so that the Cursor() function will return Pointer cursor on the next invocation - but it seems like it calls Cursor first, and only once, where on Mac/Windows, it either must call cursor twice, or calls it after MouseIn.

I think we can either remove Hyperlink from that test, or else correct for this platform difference in the driver

The behavior on Ubuntu for an actual, visible window with a hyperlink manually being hovered is correct

Edit: The order of operations when a mouse move happens is indeed to a) ask the widget for its cursor type, and b) inform the widget of the mouse movement if it is mousable. And - tested on MacOS - if you move the mouse just one pixel to enter the focus area of the hyperlink, the hyperlink underlines itself - since the text area is hovered - but the cursor does not change (until the next mouse movement). So I'm surprised the unit test passed at all on Mac or Windows, but it does seem that switching the order of operations would be correct, since widgets should be first informed about the mouse position before they are asked what cursor should be drawn. I'll hold off on making that change @andydotxyz until you OK the plan.

I also had initially forgotten to handle text alignment, and those changes are pushed now.

dweymouth added a commit to dweymouth/fyne that referenced this pull request Oct 19, 2023
Jacalz
Jacalz previously approved these changes Nov 7, 2023
Copy link
Member

@Jacalz Jacalz left a comment

Choose a reason for hiding this comment

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

Nice. Well done :)

Copy link
Member

@andydotxyz andydotxyz left a comment

Choose a reason for hiding this comment

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

This looks like a great fix, I agree with the change in order of cursor lookup.
But has it caused more test failures? Attempting to re-run the 3 failures

@andydotxyz
Copy link
Member

I cannot re-run them but it seems that the cursor tests on Ubuntu are all failing?

@andydotxyz
Copy link
Member

@dweymouth it looks like tests are failing on Ubuntu due to some Cursor issues.
Can you check it out and see if perhaps they were testing for the wrong thing with the previous behaviour?

Copy link
Member

@andydotxyz andydotxyz left a comment

Choose a reason for hiding this comment

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

To resolve test failures on Linux

@dweymouth
Copy link
Contributor Author

From what I could tell the tests were failing because we actually have "incorrect" behavior - in that the widget is asked for its cursor type before the mouse move is processed, so if the mouse moves in one event onto the hyperlink's tappable area, the cursor doesn't actually change until the next mouse event.

I am on vacation right now so probably won't really look at this until next week, so if someone wanted to take it over, go for it! But the problem was that the Cursor function is called synchronously while mouse events were placed in an event queue before being sent to the widget. So the challenge is to find out a way to ensure Cursorable widgets always have their Cursor function called after each mouse movement, so if they need to update their cursor type in response to the mouse movement, they can do so.

@Jacalz
Copy link
Member

Jacalz commented Dec 30, 2023

It would be nice to get this landed. Just a friendly reminder so to say :)

@dweymouth
Copy link
Contributor Author

I think we need @andydotxyz to make an executive decision here -

  • Do we decide we can ignore the "incorrect" behavior with little user impact, and just re-work the tests to pass and file a ticket to adjust the order of mouse and cursor processing later?
  • If not, what is the best way to go about restructuring the main loop to ensure mouse movements are processed before cursor updates?

@andydotxyz
Copy link
Member

I think the first of the two may be ok assuming the test fixes are pretty simple.
If the change can have a comment referencing the new issue tracking it would be good. I assume we can still check the desirable behaviour by triggering mouse move a second time?

@coveralls
Copy link

Coverage Status

coverage: 64.527% (-0.05%) from 64.577%
when pulling fde9a20 on dweymouth:fixes/3528
into 33809ea on fyne-io:develop.

Copy link
Member

@andydotxyz andydotxyz left a comment

Choose a reason for hiding this comment

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

Thanks

@dweymouth dweymouth merged commit 484a4bb into fyne-io:develop Jan 5, 2024
12 checks passed
@dweymouth dweymouth deleted the fixes/3528 branch January 5, 2024 15:52
@dweymouth dweymouth added this to the v2.4.4 milestone Jan 7, 2024
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.

4 participants