Skip to content

add all the pygfx events #110

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 1 commit into from
Jan 9, 2023
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
Diff view
24 changes: 18 additions & 6 deletions fastplotlib/graphics/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,22 @@
from dataclasses import dataclass


PYGFX_EVENTS = [
"key_down",
"key_up",
"pointer_down",
"pointer_move",
"pointer_up",
"pointer_enter",
"pointer_leave",
"click",
"double_click",
"wheel",
"close",
"resize",
]


class BaseGraphic:
def __init_subclass__(cls, **kwargs):
"""set the type of the graphic in lower case like "image", "line_collection", etc."""
Expand All @@ -27,10 +43,6 @@ def __init_subclass__(cls, **kwargs):


class Graphic(BaseGraphic):
pygfx_events = [
"click"
]

def __init__(
self, name: str = None):
"""
Expand Down Expand Up @@ -104,7 +116,7 @@ def link(
callback: callable = None,
bidirectional: bool = False
):
if event_type in self.pygfx_events:
if event_type in PYGFX_EVENTS:
self.world_object.add_event_handler(self.event_handler, event_type)

# make sure event is valid
Expand All @@ -117,7 +129,7 @@ def link(
feature_instance.add_event_handler(self.event_handler)

else:
raise ValueError(f"Invalid event, valid events are: {self.pygfx_events + self.feature_events}")
raise ValueError(f"Invalid event, valid events are: {PYGFX_EVENTS + self.feature_events}")

# make sure target feature is valid
if feature is not None:
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy