Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
torque-tracker TODO.txt
6.8 kB · 98 lines
at dev
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899start using AccesskitMake Cmd Q not close the App immediatelysee talk with winit maintainer on how to do this (from official winit matrix https://matrix.to/#/#rust-windowing:matrix.org):I investigated my issue a bit further and found https://github.com/rust-windowing/winit/pull/1583 where a default macOs menubar was added. This apparently also added the Cmd Q shortcut. On press this sends a command to the application to quit. I believe it would be good if this also triggered CloseRequested, although the Command isn't really associated to any specific window (so it's not a WindowEvent, but an ApplicationEvent). It seems like i have to add my own menu bar instead of using the default one.feat: added MacOS menu by casperstorm · Pull Request #1583 · rust-windowing/winit - GitHubThis is an WIP PR which shows a way we could add a generic MacOS menu into winit. Let me know what you think, if this is something you could see in this repo, then we could collaborate about the de...kchibisovwhat are you trying to achieve?luca3sI want to show a popup when a user presses Cmd Q.kchibisovhave you tried the link?luca3skchibisov luca3s: I think you can use https://docs.rs/winit/latest/winit/platform/macos/trait.WindowExtMacOS.html#tymethod.set_document_edited IIRC it should make a prompt I that's what you want.This one? yes it behaved the same as beforekchibisovif you set it to true?luca3sYes. I even added an assert that is_document_edited returns true.madsmtm luca3s I investigated my issue a bit further and found https://github.com/rust-windowing/winit/pull/1583 where a default macOs menubar was added. This apparently also added the Cmd Q shortcut. On press this sends a command to the application to quit. I believe it would be good if this also triggered CloseRequested, although the Command isn't really associated to any specific window (so it's not a WindowEvent, but an ApplicationEvent). It seems like i have to add my own menu bar instead of using the default one.The menu bar action should probably use stop: instead of terminate:luca3sHm i just tried to change that, but it doesn't change the behaviour. My setup is working, when i put a nonsense string in there the Cmd Q shortcut stops working completely.Another thing i noticed now is that this apparently is independent of the dock right click menu, which also has a option to quit the application. Do you know where this is defined? Or is it a Macos default?madsmtmSpecifies to call NSApplication methods, respectively -[NSApplication stop:] or -[NSApplication terminate:]stop(_:) | Apple Developer Documentation - Apple Developer DocumentationStops the main event loop.terminate(_:) | Apple Developer Documentation - Apple Developer DocumentationTerminates the receiver.Pretty sure dock menu cannot be changed thoughOr then again, maybe it can with https://developer.apple.com/documentation/appkit/nsapplicationdelegate/applicationdockmenu(_:)?language=objcapplicationDockMenu(_:) | Apple Developer Documentation - Apple Developer DocumentationReturns the app’s dock menu.luca3s madsmtm Pretty sure dock menu cannot be changed thoughI have an App that uses SDL2 that reacts to the Dock in the same way as to Cmd Q and close via window decorators. So it is definetly possible.luca3s madsmtm Specifies to call NSApplication methods, respectively -[NSApplication stop:] or -[NSApplication terminate:]it sounds like stop: should work... hm maybe i did something wrong. It should just be replacing terminate: with stop: inside of the "sel" macro right? From the Documentation it seems like one could also use https://developer.apple.com/documentation/appkit/nsapplicationdelegate/applicationshouldterminate(_:)?language=objc to cancel termination.applicationShouldTerminate(_:) | Apple Developer Documentation - Apple Developer DocumentationReturns a value that indicates if the app should terminate.madsmtmNo, applicationShouldTerminate is called by AppKit when shutting down, you don't request it yourselfAnd yeah, replace in sel! macroAh, you mean intercept applicationShouldTerminateOr override itYeah, that could be done, though we recently decided not to install our own NSApplicationDelegateSee https://github.com/rust-windowing/winit/pull/3758Allow the user to register the application delegate on macOS and iOS by madsmtm · Pull Request #3758 · rust-windowing/winit - GitHubRegister for event-loop lifecycle events using the NSNotification API instead of application delegates. This gives the user full control over the application delegate, which opens several doors for...So that's something you'd have to implement yourself(In the next version of winit at least)luca3s madsmtm So that's something you'd have to implement yourselfis that in regard to the Dock menu behaviour or also the menu bar behaviour? Dock is not that important to me honestlymadsmtmmenu barThough doing so, you'd handle dock correctly as wellluca3sLet's say i only want to change the menu bar behaviour. Would you recommend to overwrite the menu entry with my own or implement applicationShouldTerminate? I have never worked with MacOs APIsmadsmtmHmm. Kinda difficult with Winit v0.30, since that takes control over the NSApplicationDelegate. If you're stuck on that version, I think I'd recommend forking, and modifying the NSApplicationDelegate, somewhere around here:https://github.com/rust-windowing/winit/blob/v0.30.x/src/platform_impl/macos/app_state.rs#L63-L73To implement applicationShouldTerminate.winit/src/platform_impl/macos/app_state.rs at v0.30.x · rust-windowing/winit - GitHubWindow handling library in pure Rust. Contribute to rust-windowing/winit development by creating an account on GitHub.With Winit v0.31, you'd do the same, except instead of forking, you'd add an object similar to the ApplicationDelegate in Winit v0.30 using objc2, and register it with NSApplication::setDelegate.Thinking about it, I don't think changing terminate: to stop: would really solve your problemSince both of those still shut down the applicationI guess with stop:, you have the benefit of being able to start it again (EventLoop::run_on_demand).luca3sIs winit 0.31 out? It's not time sensitive at all so i could wait for that. Would it be possible to use something like https://docs.rs/muda/latest/muda/ to overwrite the Menu Bar entry and send me a winit event? That way i wouldn't use stop or terminate and it would be a lot easier for me. I don't really want to overwrite all the ways to close the App, just Cmd Q as it is so easy to press by mistake.muda - Rustmuda is a Menu Utilities library for Desktop Applications.madsmtmRight, yeah, muda is an option