nsbutton

Cocoa/OSX - NSWindow standardWindowButton behaving strangely once copied and added again

佐手、 提交于 2019-11-30 02:45:14
In my app I change the position of the standardWindowButtons close / miniturize / expand like so: //Create the buttons NSButton *minitButton = [NSWindow standardWindowButton:NSWindowMiniaturizeButton forStyleMask:window.styleMask]; NSButton *closeButton = [NSWindow standardWindowButton:NSWindowCloseButton forStyleMask:window.styleMask]; NSButton *fullScreenButton = [NSWindow standardWindowButton:NSWindowZoomButton forStyleMask:window.styleMask]; //set their location [closeButton setFrame:CGRectMake(7+70, window.frame.size.height - 22 - 52, closeButton.frame.size.width, closeButton.frame.size

Using -setImage on NSButton

依然范特西╮ 提交于 2019-11-29 12:49:01
I am trying to make an image an button (NSButton) in a Cocoa application, below is the code I am trying to use: [mrButton setImage:(NSImage *)@"button.jpg"]; I have linked mrButton to an NSButton in interface builder and I have a file within my Xcode project called button.jpg and I was wondering how I would go about correcting this code or making an NSButton an image. Thanks in advance! This should work: [mrButton setImage:[NSImage imageNamed:@"button.jpg"]]; 来源: https://stackoverflow.com/questions/6929409/using-setimage-on-nsbutton

Cocoa/OSX - NSWindow standardWindowButton behaving strangely once copied and added again

夙愿已清 提交于 2019-11-28 23:07:49
问题 In my app I change the position of the standardWindowButtons close / miniturize / expand like so: //Create the buttons NSButton *minitButton = [NSWindow standardWindowButton:NSWindowMiniaturizeButton forStyleMask:window.styleMask]; NSButton *closeButton = [NSWindow standardWindowButton:NSWindowCloseButton forStyleMask:window.styleMask]; NSButton *fullScreenButton = [NSWindow standardWindowButton:NSWindowZoomButton forStyleMask:window.styleMask]; //set their location [closeButton setFrame

NSButton how to color the text

天涯浪子 提交于 2019-11-28 17:30:13
on OSX I have an NSButton with a pretty dark image and unfortunately it is not possible to change the color using the attributes inspector. See picture the big black button, the text is Go . Any clues for a possibility to change the text color? I looked in to the NSButton class but there is no method to do that. I´m aware that I could make the image with white font but that is not what I want to do. Greetings from Switzerland, Ronald Hofmann --- Denis Here is two other solutions: http://denis-druz.okis.ru/news.534557.Text-Color-in-NSButton.html solution 1: -(void)awakeFromNib { NSColor *color

Using -setImage on NSButton

不问归期 提交于 2019-11-28 06:46:49
问题 I am trying to make an image an button (NSButton) in a Cocoa application, below is the code I am trying to use: [mrButton setImage:(NSImage *)@"button.jpg"]; I have linked mrButton to an NSButton in interface builder and I have a file within my Xcode project called button.jpg and I was wondering how I would go about correcting this code or making an NSButton an image. Thanks in advance! 回答1: This should work: [mrButton setImage:[NSImage imageNamed:@"button.jpg"]]; 来源: https://stackoverflow

NSButton in Catalina has no selected state

陌路散爱 提交于 2019-11-28 00:50:24
问题 I have an NSButton set as a checkbox with the following code on Catalina (Mojave is fine): let checkbox = NSButton(frame: NSRect(x: 0, y: 0, width: 200, height: 32)) checkbox.setButtonType(.switch) checkbox.title = "Sustain" checkbox.state = .off self.view.addSubview(checkbox) It looks fine when I load the app But as soon as I check it, the tick mark that I expect to be there isn't there If I load up the visual hierarchy debugger I can see it fine, I've tried putting this code straight onto a

Borderless NSButton turns gray when clicked

怎甘沉沦 提交于 2019-11-27 12:39:00
I am making a little application with three NSButtons with an image set. These buttons have no border nor background. However, when I click a button it turns into a gray rectangle. How can I fix this? Thanks. Make your button type as NSMomentaryChangeButton . [myBtn setButtonType:NSMomentaryChangeButton]; If you use NSMomentaryPushInButton then you may get gray rectangle over the button when click. Sean Rich You should be able to adjust this by changing the state mask. To do so, check out the highlightsBy: and showsStateBy: properties of NSButtonCell - they are for setting the press effect and

Cocoa: change cursor when it's over an NSButton

一笑奈何 提交于 2019-11-26 16:43:45
问题 How can I change the cursor when it's over an NSButton? 回答1: [yourButton addCursorRect:[yourButton bounds] cursor:[theCursorYouWant]]; 回答2: You should subclass NSButton first, then add the code below. - (void)resetCursorRects { if (self.cursor) { [self addCursorRect:[self bounds] cursor: self.cursor]; } else { [super resetCursorRects]; } } Now you can set cursor as you like. [self.button setCursor:[NSCursor pointingHandCursor]]; Note: add cursor as a property of your subclass, like this:

Borderless NSButton turns gray when clicked

时间秒杀一切 提交于 2019-11-26 16:05:41
问题 I am making a little application with three NSButtons with an image set. These buttons have no border nor background. However, when I click a button it turns into a gray rectangle. How can I fix this? Thanks. 回答1: Make your button type as NSMomentaryChangeButton . [myBtn setButtonType:NSMomentaryChangeButton]; If you use NSMomentaryPushInButton then you may get gray rectangle over the button when click. 回答2: You should be able to adjust this by changing the state mask. To do so, check out the