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

Add default flag toButton #2820

Merged
merged 5 commits into from Jun 6, 2023
Merged

Add default flag toButton #2820

merged 5 commits into from Jun 6, 2023

Conversation

FloVanGH
Copy link
Member

@FloVanGH FloVanGH commented Jun 5, 2023

No description provided.

@@ -40,6 +40,7 @@ A simple button. Common types of buttons can also be created with [`StandardButt
- **`icon`** (_in_ _image_): The image to show in the button. Note that not all styles support drawing icons.
- **`pressed`**: (_out_ _bool_): Set to true when the button is pressed.
- **`text`** (_in_ _string_): The text written in the button.
- **`default`** (_in_ _bool_): Defines the button as default button and display it in a highlighted color.
Copy link
Member

Choose a reason for hiding this comment

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

This says it displays it in a highlighted color and that it defines the button as a "default" button. The documentation here needs to say what that means.

IMO such a default attribute should not only configure the visual appearance but also the semantics: If I choose default: true; I want it so that when the user presses "Enter" in a dialog, this button gets activated.

So either the property here configures only the visuals - and then the docs should say just that - or the docs should explain what "default" means and this PR should implement it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, then maybe it would make more sense to rename the property as primary, to define it as visual setting.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

There is what the Qt docs say: https://doc.qt.io/qt-6/qpushbutton.html#default-prop

I'm not sure about that behavior. If we have only the default property and its enable automatically the default` behavior and you cannot use the button in the highlight/default look and feel without that behavior. Therefore e.g. in my former WPF projects, there was mostly a primary style for buttons and the behavior was defined for the specific context e.g. for dialogs, without to integrate it with the button. @tronical @ogoffart, what do you think. Integrate the default behavior or only integrate a flag to show a button as highlighted in the accent color?

Copy link
Member

Choose a reason for hiding this comment

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

you cannot use the button in the highlight/default look and feel without that behavior.

Do you know of an example where you want assign a button to have the primary role but not respond to the return key?

Apple is suggesting the same behavior for primary buttons, btw: https://developer.apple.com/design/human-interface-guidelines/buttons#Role

IMO the best API is a boolean primary property that

  1. Helps the style to give the button the appearance that will guide the user to choosing this with highest probability.
  2. Helps the compiler / run-time library to connect this to a key fallback handler in our Dialog perhaps to achieve the correct behavior.
  3. Makes the developer/designer (reader of the .slint file) that this is a primary button.

We could go for two different properties, one just for the visual appearance and one to additionally enable return-key behavior, but I'd like to understand what the use-case would be for such a styled button that should look like a primary button but not behave like one.

Copy link
Member

Choose a reason for hiding this comment

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

FWIW, we could also have a boolean primary property now that just covers the visual bit and we implement support for central Return handling later. That's kind of what your patch does. What do you think?

I'd be okay with that, as long as the documentation is clear and we track the missing "Return" handling in an issue - so that our conclusion and decision is on record ;)

Copy link
Member Author

@FloVanGH FloVanGH Jun 5, 2023

Choose a reason for hiding this comment

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

Yes I know about that it is a recommended use case for default/primary button.

I have no other specific use case in mind. I was only thinking because we support multiple design systems and maybe there could be a use case for a specific design system in the future. But maybe this thought is too theoretically and if there will be such a use case we will find an other way to handle it.

Copy link
Member Author

Choose a reason for hiding this comment

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

If we implement that feature. Would it make sense to integrate the default/primary property also for TouchArea, then a developer/ designer can also make use of it for the creation of a custom button in Slint.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure about TouchArea (that seems unrelated to keyboard handling to me), but you're right: We almost have this with the dialog-button-role, except that it's only for dialogs and only affects the layout.

Okay, I'm getting convinced that we should go with primary as visual-only property for now :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay. I have updated the property name to primary and also adjusted the documentation.

Copy link
Member

@tronical tronical left a comment

Choose a reason for hiding this comment

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

LGTM. Let's see what Olivier says :)

CHANGELOG.md Outdated Show resolved Hide resolved
docs/language/src/builtins/widgets.md Outdated Show resolved Hide resolved
examples/gallery/ui/pages/controls_page.slint Outdated Show resolved Hide resolved
examples/gallery/ui/pages/controls_page.slint Outdated Show resolved Hide resolved
FloVanGH and others added 5 commits June 6, 2023 15:40
Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>
Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>
@FloVanGH FloVanGH merged commit 94a0327 into master Jun 6, 2023
16 of 21 checks passed
@FloVanGH FloVanGH deleted the florian/default-button branch June 6, 2023 13:41
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

3 participants