-
Notifications
You must be signed in to change notification settings - Fork 12
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
keyboard, space bar
or enter
cannot trigger a button clicking
#20
Comments
Hi, thank you for your feedback and suggestions. Please keep on filing feature requests so that I have a better idea of what people want or need in their projects. I'll take a look at keyboard bindings and figure out the best way to incorporate them. |
I've confirmed this that Space and Enter do not fire https://doc.qt.io/qtforpython-6/PySide6/QtWidgets/QPushButton.html#detailed-description
|
Ah it’s because edifice is using |
I tried to solve this by making the So I tried this other way and this works, but it uses a different @register_props
def __init__(self,
layout: str = "row",
on_trigger: tp.Callable[[QKeyEvent], None] | tp.Callable[[QMouseEvent], None] | None = None,
**kwargs):
super().__init__(layout, **kwargs) def _set_on_trigger(self, underlying, on_trigger):
if on_trigger is not None:
def on_click(ev:QMouseEvent):
on_trigger(ev)
def on_key(ev:QKeyEvent):
if ev.text() == " " or ev.text() == "\r":
on_trigger(ev)
self._set_on_click(underlying, on_click)
self._set_on_key_up(underlying, on_key)
def _qt_update_commands(self, children, newprops, newstate):
if self.underlying is None:
self._initialize()
commands = super()._qt_update_commands(children, newprops, newstate)
for prop in newprops:
if prop == "on_trigger":
commands.append((self._set_on_trigger, self.underlying, newprops.on_trigger))
commands.append((self.underlying.setCursor, Qt.PointingHandCursor))
return commands |
The We should think about how we want to generally handle this problem with the Base |
pressing
space bar
when focusing on a button will trigger an animation of button click, but the button'son_click
is not called, have to use mouse to do a "real click"while pressing
enter
cannot even generate a button clicked animationp.s. this project has very promising future, but current version still very incomplete, i would hope to be more skillful to contribute to this project but right now i'm a newbie especially in Qt
The text was updated successfully, but these errors were encountered: