ryanmcgrath / cacao

Rust bindings for AppKit (macOS) and UIKit (iOS/tvOS). Experimental, but working!
MIT License
1.79k stars 65 forks source link

Setting window level #114

Closed niknbr closed 7 months ago

niknbr commented 7 months ago

Is there a way to set the window level ?

If not, I was trying to understand how it can be done similar to the window style, but could you please explain how these enum values are converted to NSUInteger

https://github.com/ryanmcgrath/cacao/blob/0f64a843627caeb901705e246c4fc5d6ddbf964d/src/appkit/window/enums.rs#L48-L59

ryanmcgrath commented 7 months ago

In these cases it's generally calling .into() on a type hinted NSUInteger declaration or param.

niknbr commented 7 months ago

@ryanmcgrath I meant what is the value on the right side signify. For eg in WindowStyle::FullSizeContentView => 1 << 15, what is 1 << 15 exactly ? Sorry, not familiar with these apis.

ryanmcgrath commented 7 months ago

It's just a direct translation of the APIs, e.g:

https://developer.apple.com/documentation/appkit/nswindowstylemask/nswindowstylemasktitled

(NSWindowStyleMask is an NSUInteger)

niknbr commented 7 months ago

Ah ok. Thank you. Would an implementation for window level be similar to this ? Any hints in that direction ? 🙂

ryanmcgrath commented 7 months ago

It likely would be similar, yes - though in typical Apple fashion the web docs lack context and you'll need to dig up the headers to find the right values:

https://developer.apple.com/documentation/appkit/nsfloatingwindowlevel?language=objc

And then also implement this:

https://developer.apple.com/documentation/appkit/nswindow/1419511-level?language=objc

And consider the orderIn/orderOut methods if you find them useful.

niknbr commented 7 months ago

Thanks, new to this, but will give it a shot