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

feat: button improvements #1187

Merged
merged 4 commits into from
Oct 11, 2024
Merged

feat: button improvements #1187

merged 4 commits into from
Oct 11, 2024

Conversation

w-lfchen
Copy link
Contributor

@w-lfchen w-lfchen commented Sep 1, 2024

Description

  • supersedes Make onclick trigger for both mouse and keyboard #640 (that pr can be closed)
  • buttons can be activated using the keyboard now
  • if buttons play animations on click (catppuccin gtk theme for example), these are now played when they are right-/middleclicked as well
  • buttons and eventboxes now consistently activate on key/button release
  • some more cleanup in widget_definitions.rs

Usage

currently supported keys:

  • space
  • return/enter

Showcase

here's the config i tested with:

(defvar left 0)
(defvar mid 0)
(defvar right 0)
(defwindow example
  :monitor 0
  :focusable true
  :geometry (geometry
    :width "100%"
    :height "30px"
    :anchor "top center"
  )
  (button
    :onclick "eww update left=${left+1}"
    :onmiddleclick "eww update mid=${mid+1}"
    :onrightclick "eww update right=${right+1}; eww close example"
    "l: ${left}, m: ${mid}, r: ${right}"
  ))

Additional Notes

we could achieve a bit better performance if we don't want the fancy animation support.
i think the trade-off is worth it, but if you (the person reading this) think differently, feel free to comment. testing is also appreciated

⚠️ help wanted ⚠️

i've attempted to implement this logic for eventboxes as well and failed, i don't think this is possible for those, but i'm not sure.
i'd appreaciate it a lot if someone could investigate this further (in a new pr so that this one can be merged)

Checklist

  • I added my changes to CHANGELOG.md, if appropriate.
  • The documentation in the docs/content/main directory has been adjusted to reflect my changes.
  • I used cargo fmt to automatically format all code before committing

@w-lfchen w-lfchen changed the title Feat/button feat: button improvements Sep 1, 2024
@w-lfchen w-lfchen marked this pull request as draft September 2, 2024 08:56
@w-lfchen
Copy link
Contributor Author

w-lfchen commented Sep 2, 2024

investigating some things

@elkowar
Copy link
Owner

elkowar commented Oct 11, 2024

This looks pretty good! We should investigate the event box stuff at some point, but for now this should suffice! Thanks a lot!

@elkowar elkowar merged commit 8de378d into elkowar:master Oct 11, 2024
1 check passed
@w-lfchen w-lfchen deleted the feat/button branch October 11, 2024 12: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.

2 participants