8000 Feat(Widget.EventBox): Add support for right & left scroll events by regenman · Pull Request #82 · linkfrg/ignis · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
/ ignis Public
< 8000 /div>

Feat(Widget.EventBox): Add support for right & left scroll events #82

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

Merged
merged 2 commits into from
Dec 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
8000
Diff view
38 changes: 37 additions & 1 deletion ignis/widgets/eventbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class EventBox(Box):
on_hover_lost=lambda self: print("hover lost((("),
on_scroll_up=lambda self: print("scrolled up!"),
on_scroll_down=lambda self: print("scrolled down!")
on_scroll_right=lambda self: print("scrolled right!")
on_scroll_left=lambda self: print("scrolled left!"),
)
"""

Expand All @@ -36,6 +38,8 @@ def __init__(self, **kwargs):
self._on_hover_lost: Callable | None = None
self._on_scroll_up: Callable | None = None
self._on_scroll_down: Callable | None = None
self._on_scroll_right: Callable | None = None
self._on_scroll_left: Callable | None = None

self.__click_controller: Union[Gtk.GestureClick, None] = None
self.__right_click_controller: Union[Gtk.GestureClick, None] = None
Expand Down Expand Up @@ -85,8 +89,12 @@ def __on_scroll(
):
if dy > 0 and self.on_scroll_up:
self.on_scroll_up(self)
elif self.on_scroll_down:
elif dy < 0 and self.on_scroll_down:
self.on_scroll_down(self)
if dx > 0 and self.on_scroll_right:
self.on_scroll_right(self)
elif dx < 0 and self.on_scroll_left:
self.on_scroll_left(self)

def __pointer_enter(self, event_controller_motion, x, y) -> None:
if self.on_hover:
Expand Down Expand Up @@ -203,3 +211,31 @@ def on_scroll_down(self) -> Callable:
def on_scroll_down(self, on_scroll_down: Callable) -> None:
self._on_scroll_down = on_scroll_down
self.__init_scroll_controller()

@GObject.Property
def on_scroll_right(self) -> Callable:
"""
- optional, read-write

The function to call on scroll right.
"""
return self._on_scroll_right

@on_scroll_right.setter
def on_scroll_right(self, on_scroll_right: Callable) -> None:
self._on_scroll_right = on_scroll_right
self.__init_scroll_controller()

@GObject.Property
def on_scroll_left(self) -> Callable:
"""
- optional, read-write

The function to call on scroll left.
"""
return self._on_scroll_left

@on_scroll_left.setter
def on_scroll_left(self, on_scroll_left: Callable) -> None:
self._on_scroll_left = on_scroll_left
self.__init_scroll_controller()
Loading
0