e9a65bb15d591ec22649e03659db8095d4f2dd60
Add bindings for NSOpenPanel
This PR adds bindings for the main `NSOpenPanel` APIs, which let you present a modal for selecting files or directories. Usage:
```rust
let panel = NSOpenPanel::openPanel(nil);
panel.setCanChooseDirectories_(YES);
panel.setCanChooseFiles_(NO);
panel.setAllowsMultipleSelection_(YES);
let response = panel.runModal();
if response == NSModalResponse::NSModalResponseOk {
let urls = panel.URLs();
for i in 0..urls.count() {
let url_ptr = urls.objectAtIndex(i).absoluteString().UTF8String();
let url = CStr::from_ptr(url_ptr).to_string_lossy();
eprintln!("You picked URL {}", url);
}
}
```
core-foundation-rs
Compatibility
Targets macOS 10.7 by default.
To enable features added in macOS 10.8, set Cargo feature mac_os_10_8_features. To have both 10.8 features and 10.7 compatibility, also set mac_os_10_7_support. Setting both requires weak linkage, which is a nightly-only feature as of Rust 1.19.
For more experimental but more complete, generated bindings take a look at https://github.com/michaelwu/RustKit.
Description
Languages
Rust
100%