Aylur / astal

Building blocks for creating custom desktop shells
https://aylur.github.io/astal/
GNU Lesser General Public License v2.1
279 stars 35 forks source link

Detect mouse scroll direction on button #94

Closed danielwerg closed 1 week ago

danielwerg commented 1 week ago

Have you read through the documentation?

Describe what have you tried so far

<button
  cursor='pointer'
  onScroll={(_, event) => print(event.direction)}
>
  <label label='scroll me' />
</button>

Describe your question

Trying to implement wireplumber volume change on mouse scroll up/down, same way I have it setup in waybar:

https://github.com/user-attachments/assets/c1a5f327-886d-4363-8059-f2050c31a505

I'm always getting 4, no matter what direction I scroll. Looking at GTK docs on this 4 = GDK_SCROLL_SMOOTH

Do I need to fake scrolling area somehow in order for this to work or is there a nicer way to do this?

Aylur commented 1 week ago

I don't remember what direction is for exactly, but you can use delta_y and delta_x to determine direction

danielwerg commented 1 week ago

I think I tested delta_x twice instead of testing delta_y, thanks ;D

onScroll={(_, event) => print(event.delta_y > 0 ? 'down' : 'up')}