nsbutton

How to change the background color of an NSPopupButton?

十年热恋 提交于 2021-02-08 15:54:46
问题 I am trying to tackle a problem which sounds pretty simple: changing the background color of an NSPopupButton. Interface Builder only allows changing the style to a pre-defined one and doesn't allow changing the background color. Also, setting up an IBOutlet didn't help since NSPopupButton doesn't have a setBackgroundColor method. I also tried subclassing NSPopupButton to override the drawRect method. Here's what I have tried: - (void)drawRect:(NSRect)dirtyRect { [[NSColor redColor] setFill];

How to change the background color of an NSPopupButton?

天大地大妈咪最大 提交于 2021-02-08 15:54:00
问题 I am trying to tackle a problem which sounds pretty simple: changing the background color of an NSPopupButton. Interface Builder only allows changing the style to a pre-defined one and doesn't allow changing the background color. Also, setting up an IBOutlet didn't help since NSPopupButton doesn't have a setBackgroundColor method. I also tried subclassing NSPopupButton to override the drawRect method. Here's what I have tried: - (void)drawRect:(NSRect)dirtyRect { [[NSColor redColor] setFill];

how to code NSButton to look just like image

為{幸葍}努か 提交于 2021-01-26 19:49:36
问题 Using code (not the Interface builder) I need to create an NSButton that looks like an image. Specifically I want to use NSImageNameStopProgressFreestandingTemplate and I need it not to look like button but to look like the image. This means: 1. No 'button down' look 2. No border, no any visibility of the button Thanks. 回答1: I know this response is a bit late, but you could try this, given thisButton : [thisButton setImage:[NSImage imageNamed:NSImageNameStopProgressFreestandingTemplate]];

how to code NSButton to look just like image

痞子三分冷 提交于 2021-01-26 19:43:34
问题 Using code (not the Interface builder) I need to create an NSButton that looks like an image. Specifically I want to use NSImageNameStopProgressFreestandingTemplate and I need it not to look like button but to look like the image. This means: 1. No 'button down' look 2. No border, no any visibility of the button Thanks. 回答1: I know this response is a bit late, but you could try this, given thisButton : [thisButton setImage:[NSImage imageNamed:NSImageNameStopProgressFreestandingTemplate]];

how to code NSButton to look just like image

只谈情不闲聊 提交于 2021-01-26 19:42:31
问题 Using code (not the Interface builder) I need to create an NSButton that looks like an image. Specifically I want to use NSImageNameStopProgressFreestandingTemplate and I need it not to look like button but to look like the image. This means: 1. No 'button down' look 2. No border, no any visibility of the button Thanks. 回答1: I know this response is a bit late, but you could try this, given thisButton : [thisButton setImage:[NSImage imageNamed:NSImageNameStopProgressFreestandingTemplate]];

NSButton setImage not working

半城伤御伤魂 提交于 2020-01-25 10:37:08
问题 I am trying to change the image of my nsbutton for my application. I have searched and found a couple of ways to do so but none of them are working for me at the moment. I have looked at the following solutions : How to set NSButton background image Using -setImage on NSButton I have a routine that is called when I click the button : - (IBAction)pauseResumeButtonAction:(id)sender { IAgentInterface* agentInterface = ioc::Container::Resolve(); if (self.pauseResumeSwitch == PauseResumeSwitch:

NSButton - Hit Testing rollover/hover for custom shaped buttons

霸气de小男生 提交于 2020-01-15 05:29:09
问题 (Targeting OS X 10.10, latest version of Xcode) I have an NSButton subclass. The button needs to respond to mouse rollovers/hovers, ala a web button. The button requires an appearance in the shape of a circle. Accordingly, -setImage: and -setAlternateImage: are called with circular-shaped graphics. Problem 1: the default behaviour of NSButton results in a positive hit-test when the mouse is clicked anywhere within the rect of the NSButton. This includes mouse clicks that are outside the

create nsbutton manually - call function

别说谁变了你拦得住时间么 提交于 2020-01-06 04:35:26
问题 This question probably is trivial but I am searching for hours now and just dont find the fitting link. I am programming a board game with many fields like a chess board. I managed to create all fields as buttons with for ... in and code like this: let feld = NSButton() feld.frame = CGRect(x: 1300+30*h, y: 20, width: 22, height: 22) feld.image = NSImage(named: NSImage.Name("Mulleimer")) arrayOfButtons.append(feld) When a button is pressed I want to start a function. How to do this!? I only

Change color to a title of a button in Swift [duplicate]

泪湿孤枕 提交于 2020-01-05 08:12:34
问题 This question already has answers here : Swift Mac OSX NSButton title color (3 answers) Closed 3 years ago . I have problems changing the color of the title of a NSButton. I tried this: button.setTitleColor(NSColor.blackColor()) or this button.titleColor = NSColor.blackColor() and this button.title.textColor = NSColor.blackColor() but none of these three methods seems to be available! How could that be possible, the compiler says that these method are not present. AppKit and Cocoa are

Checking if NSButton is down on drawRect

自闭症网瘾萝莉.ら 提交于 2020-01-03 10:59:08
问题 I would like to check if my custom NSButton is currently in a pressed state (the user is clicking down on it) in my custom drawRect method. Something like this: - (void)drawRect:(NSRect)dirtyRect{ if ([self buttonIsInPressedState]) { [[self alternateBGImage] drawInRect:dirtyRect fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0f]; }else{ [[self BGImage] drawInRect:dirtyRect fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0f]; } [super drawRect:dirtyRect]; } How