Closed Gremious closed 3 weeks ago
Ideally, we want to keep widgets as simple as possible and with a single purpose. I think you could achieve something similar with the MouseArea
widget.
Additionally, buttons with a right click handler are not very common and, therefore, not ideal for UX.
Mouse area is what I have right now, and the reason for this PR.
I cannot nicely achieve similar things with a mouse area, as I cannot easily re-create a button: I cannot style a mouse area or the container around it on hover (https://github.com/iced-rs/iced/issues/972 + mouse area doesn't have on_hover), and creating the on-click (active) styling also suddenly becomes cumbersome if I'm gonna be sending messaged and rebuilding elements just to restyle for a brief moment (compared to just having a button which already does that underneath).
(Plus, when i'm doing messges like this, the timing of that doesn't seem as smooth/nice as what buttons do? Might be a me issue.)
I didn't, then, want to copy-paste the entire button widget in my own code and only add those few lines.
So, I felt like contributing this simple case. I implore you to reconsider, but if not, I guess I have to go the annoying route of having my own button widget, or having the clutter of a bunch of mesaages bouncing back and forth with different near-identical containers switching places for a simple button. I do need right clickable buttons.
buttons with a right click handler are not very common and, therefore, not ideal for UX.
They are good UX in my case..? Sorry, I don't think this is applicable for me.
My app needs buttons that are right-clickable as a secondary, alternative action.
I am adding a very simple
on_press_alt
to go alongsideon_press
:on_press
or else be disabled, as usual. Whetheron_press_alt
is missing or present is irrelevant.on_press_alt_maybe
- only removing theon_press
counts as disabling the button. a) Which is why it checks whether both are present before allowingstate.is_pressed_alt = true;
I have tested this on the counter example. It sends different messages ok and styles the button on ether click if present. Disabling
on_press
re-styles as disabled and stops both from working as expected.