Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upchore: add simple NSControl class #272
Merged
Conversation
|
@bors-servo r+ |
|
|
bors-servo
added a commit
that referenced
this pull request
Nov 8, 2018
…button, r=jdm
chore: add simple NSControl class
I needed to use `[button setEnabled]` for an `NSButton`, so I added some of `NSControl`'s basic functionality.
Example usage:
```rust
use cocoa::foundation::NSRect;
use cocoa::appkit::{NSButton, NSControl, NSView};
// Parent view
let view = NSView::alloc(nil)
.initWithFrame_(NSRect::new(NSPoint::new(0., 0.), NSSize::new(200., 200.)));
// Add button to view
let button = NSButton::alloc(nil)
.initWithFrame_(NSRect::new(NSPoint::new(20., 20.), NSSize::new(150., 50.)));
NSView::addSubview_(view, button);
// Prints "1" (button enabled)
println!("{:?}", NSControl::isEnabled_(button));
// Disable the button
NSControl::setEnabled_(button, NO);
// Prints "0" (button disabled)
println!("{:?}", NSControl::isEnabled_(button));
```
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/core-foundation-rs/272)
<!-- Reviewable:end -->
|
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
acheronfail commentedNov 8, 2018
•
edited by larsbergstrom
I needed to use
[button setEnabled]for anNSButton, so I added some ofNSControl's basic functionality.Example usage:
This change is