Skip to content
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

Allow some events to perform cancellation. #3349

Open
Misaka299 opened this issue Jan 1, 2024 · 4 comments
Open

Allow some events to perform cancellation. #3349

Misaka299 opened this issue Jan 1, 2024 · 4 comments
Labels
S - enhancement Wouldn't this be the coolest?

Comments

@Misaka299
Copy link

For example, in the WindowEvent::Resized method, if the calculation result does not meet my requirements or settings. I can cancel the execution of this event by returning false or other methods.

@daxpedda daxpedda added the S - enhancement Wouldn't this be the coolest? label Jan 2, 2024
@daxpedda
Copy link
Member

daxpedda commented Jan 2, 2024

I don't know if this is possible in other backends, but it's not possible in Web.

@madsmtm
Copy link
Member

madsmtm commented Jan 2, 2024

I think maybe -[NSWindowDelegate windowwillresize] would be able to provide what you need on macOS, can you confirm that's what you need?

(Using that is problematic though, because it works with the outer size of the window, not the inner size).

(And winit generally does not support callbacks (the ScaleFactorChanged event is terrible), so even then, implementing this would be difficult).

@Misaka299
Copy link
Author

I don't know if this is possible in other backends, but it's not possible in Web.

I don't know about the web platform. What I am currently working with is the window platform. For example, WindowEvent::Resized I mentioned above. EventLoop only provides a notification callback. The reason why the window actually changes is not other than after winit executes the EventLoop callback. Changes to the window are made from winit's code. So the current phenomenon is that no matter what is done in the callback, it is the same as not doing anything. The code in the callback only has the right to know the callback message and has no decision-making power (for example, let winit ignore the message and give up adjusting the window) .

@daxpedda
Copy link
Member

daxpedda commented Jan 3, 2024

(And winit generally does not support callbacks (the ScaleFactorChanged event is terrible), so even then, implementing this would be difficult).

It would be good to figure out an API for that first indeed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S - enhancement Wouldn't this be the coolest?
Development

No branches or pull requests

3 participants