Skip to content

raylib: simpler callbacks #35488

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 8 commits into from
Jun 7, 2025
Merged

raylib: simpler callbacks #35488

merged 8 commits into from
Jun 7, 2025

Conversation

sshane
Copy link
Contributor

@sshane sshane commented Jun 7, 2025

It seems simpler to me if the children widgets call the callback functions directly rather than telling the parent to run them via dynamic setattr.

This exposes some more touch/mouse press detection issues. Now mouse up when clicking settings will be handled by sidebar and settings, opening and closing it immediately.

We should handle this by ensuring the widget also gets the down event, not just released (a bug with other widgets too)

@sshane sshane changed the title simpler no current callback raylib: simpler callbacks Jun 7, 2025
@github-actions github-actions bot added the ui label Jun 7, 2025
@sshane
Copy link
Contributor Author

sshane commented Jun 7, 2025

@deanlee what do you think?

@deanlee
Copy link
Contributor

deanlee commented Jun 7, 2025

No, there's a reason I wrote it this way. This is a temporary workaround. Without this handling, when clicking the sidebar's settings button, the Settings view opens—but immediately detects the same mouse click as a press on the "Close" button and closes itself right away.
What we really need is a proper mechanism to intercept or consume mouse events.

@sshane
Copy link
Contributor Author

sshane commented Jun 7, 2025

I'm aware, but we already have this problem with the sidebar. If you click onroad where the settings button will be, when the sidebar pops open it brings you to settings. This PR simplifies something confusing, we'll have to fix this touch handling bug eventually

@sshane
Copy link
Contributor Author

sshane commented Jun 7, 2025

Btw #35489 fixes the settings / close button issue. It only handles cases cross-widgets, we need something nice and simple to handle intra-widget interactions, such as this one:

Peek.2025-06-06.22-22.mp4

Comment on lines +41 to 44
self._sidebar.set_callbacks(on_settings=self._on_settings_clicked,
on_flag=self._on_flag_clicked)
self._layouts[MainState.SETTINGS].set_callbacks(on_close=self._set_mode_for_state)
self._layouts[MainState.ONROAD].on_click = self._on_onrad_clicked
Copy link
Contributor Author

@sshane sshane Jun 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@deanlee let's decide on if we should use set functions or not soon, this is two different patterns for no reason

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

think using a set method for is clearer than direct assignment

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some modules, like ui_state with offroad transition, may need multiple callbacks. Using a consistent set_ / add_ pattern makes it easier to manage them than assigning callbacks directly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are your thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sshane sshane merged commit 7c51555 into master Jun 7, 2025
16 of 17 checks passed
@sshane sshane deleted the no-current-callback branch June 7, 2025 06:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants