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

Feature/buttonkeys #2263

Merged
merged 19 commits into from
Jun 3, 2021
Merged

Conversation

andydotxyz
Copy link
Member

Description:

Add focus state to Button and Hyperlink and enable space-bar to action them.
This added a new focus rect around hyperlink as is seen in web browsers:

focus
initial

Relates to #1515

Checklist:

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

@fpabl0
Copy link
Member

fpabl0 commented May 25, 2021

Could buttons and hyperlinks be actioned by tapping Enter too?

@andydotxyz
Copy link
Member Author

Could buttons and hyperlinks be actioned by tapping Enter too?

So far we have just used space for activation.
The idea of Enter was that it would be used for the primary action in forms / dialogs - so if we wire it into default buttons then we will get inconsistencies as we develop it into more complex scenarios.

widget/entry.go Outdated Show resolved Hide resolved
widget/entry.go Outdated Show resolved Hide resolved
widget/entry.go Outdated Show resolved Hide resolved
widget/entry.go Outdated Show resolved Hide resolved

### Updated

* Focusable widgets are no longer focused on tap, add canvas.Focus(obj) in Tapped handler if required
Copy link
Member

Choose a reason for hiding this comment

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

This would also mean that custom widgets that are focused when tapped cannot be extended? (Because .super() is private? 🤔)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, thanks - I missed some elements here and have tidied it all up

@fpabl0
Copy link
Member

fpabl0 commented May 26, 2021

so if we wire it into default buttons then we will get inconsistencies as we develop it into more complex scenarios.

I don't understand how Enter-key action would lead to inconsistencies as it would only work when the button is focused. 🤔

@andydotxyz
Copy link
Member Author

I don't understand how Enter-key action would lead to inconsistencies as it would only work when the button is focused. 🤔

Because depending on what widget is focused the Enter button would change from actioning an item to submitting the form.
Space has no such idea so always triggers what is focused.

@andydotxyz andydotxyz requested a review from fpabl0 May 26, 2021 13:13
internal/driver/glfw/menu_bar_test.go Show resolved Hide resolved
internal/driver/glfw/menu_bar_test.go Show resolved Hide resolved
internal/driver/glfw/menu_bar_test.go Show resolved Hide resolved
widget/button.go Outdated Show resolved Hide resolved
widget/entry.go Outdated Show resolved Hide resolved
@andydotxyz andydotxyz requested a review from fpabl0 June 2, 2021 18:28
Copy link
Member

@fpabl0 fpabl0 left a comment

Choose a reason for hiding this comment

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

LGTM, just some comments.

@@ -309,25 +334,15 @@ func (r *buttonRenderer) buttonColor() color.Color {
switch {
case r.button.Disabled():
return theme.DisabledButtonColor()
case r.button.focused:
return blendColor(theme.ButtonColor(), theme.FocusColor())
Copy link
Member

Choose a reason for hiding this comment

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

This should be the corresponding bg color depending on the importance, however I agree that the color resulted after blending with the primary color does not have any appreciable difference, maybe this could be improved if we decide in the future to change the Focus color (to something similar to MaterialDesign), this should be needed if we want different colored buttons (primary, secondary, success, danger, etc). However, for now I think it is ok :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes I wondered that as well, but it just didn't seem to look good. Maybe we can revisit it somehow, like if the focus was not a directly less-vibrant version of primary.

@andydotxyz andydotxyz merged commit fca4f9d into fyne-io:develop Jun 3, 2021
@andydotxyz andydotxyz deleted the feature/buttonkeys branch June 3, 2021 09:44
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.

None yet

2 participants