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

Button hover event #168

Conversation

sumibi-yakitori
Copy link
Contributor

Add a hover event to the button.

Hover events are called continuously when the mouse cursor moves,
but that is the same for other GUI frameworks.

Copy link
Member

@hecrj hecrj left a comment

Choose a reason for hiding this comment

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

Thanks for the suggestion!

What is the use case for this? I think hover events are normally used to change styling, and the button::StyleSheet should already take care of that.

I am wary of adding this because we do not want users to rely on on_hover to change layout either, as I feel it would be quite unintuitive. A button should not produce any effects until it is pressed.

@hecrj hecrj added the question Further information is requested label Jan 25, 2020
@hecrj hecrj added this to the 0.1.0 milestone Jan 25, 2020
@sumibi-yakitori
Copy link
Contributor Author

sumibi-yakitori commented Jan 25, 2020

I want to display the detailed information of the selected list item in another view.
It's often used when there are many items in the list, because it's faster to just hover over the button instead of clicking to see the details.

I understand that this usage is not intended for consumers who use touch devices.
But
If there are no basic features supported by other GUI frameworks,
I think the applicability to create various professional tools is not enough, so please add them if possible.

Also,
Tooltips may be a somewhat outdated use case, but still useful.

I apologize for the strange English.

@sumibi-yakitori
Copy link
Contributor Author

For example, something like this.

Screen Shot 2020-01-25 at 16 42 33

@hecrj
Copy link
Member

hecrj commented Jan 25, 2020

Yes, I think your use case is completely valid.

However, I do not believe a Button::on_hover is the best strategy for it. We want widgets to be as simple as possible and with a clear purpose. We want the library to tackle use cases directly.

In my opinion, a better alternative would be a new SelectList widget with an on_item_hover method or similar. This approach could tackle this particular use case and many others (lazily rendering items based on scrolling offset, for instance). I understand this requires a lot more effort and exploration but it should be worth it in the long run.

For the GitHub example you posted, a Tooltip widget would be the way to go, but that would need layer support (see #30).

@sumibi-yakitori
Copy link
Contributor Author

I think I could understand your design philosophy.

As you say, I still don't have enough time to understand the source code of iced.

I will try to create a simple custom widget that supports hover event.

@sumibi-yakitori sumibi-yakitori deleted the feature/button_on_hovered branch January 25, 2020 14:23
@sumibi-yakitori sumibi-yakitori restored the feature/button_on_hovered branch January 26, 2020 14:15
@sumibi-yakitori sumibi-yakitori deleted the feature/button_on_hovered branch January 26, 2020 19:40
@valpackett
Copy link
Contributor

I solved this by making a custom container widget that handles hover events (and might handle others in the future):

DankBSD/waysmoke@aa74cc5

Nicely composable :)

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

Successfully merging this pull request may close these issues.

3 participants