Skip to content

Conversation

@Riki-Sternbuch
Copy link

This change updates CTkButton to trigger its command only on instead of , matching standard OS behavior and improving UX.

@FedericoSpada
Copy link
Collaborator

Hi,
I like the idea a lot since it gives the user the possibility to change their mind before the callback is actually called.

I would also move the click animation after the Left button has been released. For this reason, starting from the original code, I would suggest modifying "Button-1" with "ButtonRelease-1" every time it appears.
Then, you can update the _clicked() function to check whether the mouse is still inside the button.

Regarding this last aspect, I think that your code is not working properly: the callback has been assigned to multiple objects (canvas, label, image), so the "event" parameter provides its x and y values with respect to different reference frames. If you always compare them with canvas dimensions, sometimes, it happens that the callback is not triggered.
To write the perfect condition, I think that you have to play with self.winfo_pointerx() and self.winfo_rootx().

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