nsbutton

NSButton background transparent after getting focus

纵然是瞬间 提交于 2019-12-06 13:50:30
问题 I have a problem with some borderless NSButtons in a view, on a transparent popover. When the popover is first opened, the buttons look exactly as they should, but when the popover (or the view inside it) gains focus, the background becomes transparent. The first time it is opened, it looks like this (As it should): But when the popover gains focus, the buttons end up like this: , where the background is transparent and the content beneath the popover is visible. I already tried the following

Add a close button to NSTabviewitem

廉价感情. 提交于 2019-12-06 08:38:53
问题 I have a application with a tab view when the user clicks in the menu for example "client data" I generate a tab programmaticaly. Now I want to subclass the tab view to add a close button for each NSTabviewitem. If you don't have an answer you could help with documentation or sample code 回答1: I know this question is ancient, but... I spent some time trying to add buttons to NSTabViewItems with a custom subclass, and as far as I can tell it's not really possible. NSTabViewItem simply isn't

NSButton image shadow on mouseEntered event

牧云@^-^@ 提交于 2019-12-06 07:12:35
I have a borderless NSButton that contains an image and is subclassed with my ButtonEffect class to detect mouseEntered and mouseExited events. My goal is to have just the edge of the image glow as the mouse enters the button area. I know I can achieve this by using two different images (one with shadow and another without) but I need to do this with one image. Here's an example of what I hope to achieve for the mouseEntered event: And here's what it should look after the cursor leaves the button area: Here's my attempt by setting the background of the cell but it changes the color of the

mouseEntered Event Disabled When mouseDown (NSEvents Mac)

两盒软妹~` 提交于 2019-12-06 03:44:16
I have created an NSButton class, and when rolling over my buttons it happily detects mouseEntered and mouseExited events. But as soon as the mouseDown event occurs, so long as the mouse it down, mouseEntered events are no longer called until the mouse button is lifted. So, when the mouseDown event is called, mouseEntered or MouseExited events are no longer called, nor is mouseDown called when rolling over other buttons until I let go of the initial mouseDown. So I would like to detect when my mouse enters while the mouse is down as well. Hope you understand, and hope you can help stop this.

Programatically create and position an NSButton in an OS X app? [closed]

做~自己de王妃 提交于 2019-12-06 03:02:51
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I need to programatically create and position a button in a Mac OS X Cocoa application. Any help would be appreciated... 回答1: To possition button You need to change the button's origins x and y. Look at the

How to force the cursor to be an “arrowCursor” when it hovers a NSButton that is inside a NSTextView?

北慕城南 提交于 2019-12-05 20:32:18
Okay, here is the problem: I have a NSTextView and I add my custom NSButton using: [_textView addSubview:button]; Then, inside my NSButton subclass, I have (along with the NSTrackingArea stuff): - (void)mouseEntered:(NSEvent *)event{ [[NSCursor arrowCursor] set]; } - (void)mouseExited:(NSEvent *)theEvent{ [[NSCursor arrowCursor] set]; } - (void)mouseDown:(NSEvent *)theEvent{ [[NSCursor arrowCursor] set]; } - (void)mouseUp:(NSEvent *)theEvent{ [[NSCursor arrowCursor] set]; } But when I hover it, the cursor remains the same IBeamCursor (because it's a NSTextView ). Only when I press the button,

Key Value Observing and NSButton state

自古美人都是妖i 提交于 2019-12-05 20:15:43
I'm trying to observe checkbox status and make appropriate changes in the app when checkbox status changes. In a window manager that manages the window with checkbox I have following observer setup: - (void)awakeFromNib { [myCheckBox addObserver:self forKeyPath:@"state" options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld) context:NULL]; } - (void)dealloc { [myCheckBox removeObserver:self forKeyPath:@"state"]; } - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { NSLog(@"KeyPath: %@", keyPath); NSLog(@

NSButton in NSTableCellView: How to find desired objectValue?

三世轮回 提交于 2019-12-05 15:22:08
I have a view-based NSTableView that is populated through bindings. My textFields & imageViews are bound to the NSTableCellView's objectValue's properties. If I want to have an edit/info button in my NSTableCellView: Who should be the target of the button's action? How would the target get the objectValue that is associated with the cell that the button is in? I'd ultimately like to show a popover/sheet based on the objectValue. Your controller class can be the target. To get the object value: - (IBAction)showPopover:(id)sender { NSButton *button = (NSButton *)sender; id representedObject = [

Lost in NSButton types and alternate images

旧城冷巷雨未停 提交于 2019-12-05 07:02:32
I’d like to have an NSButton with an image and an alternate image. The alternate image should be displayed while the button is being pressed and I’d also like to display the alternate image from code, calling something like [button setSelected:YES] . Is this possible without monkeing with the alternateImage property by hand? This is possible without manually changing the button's image: In Interface Builder (xib/nib Editor) set the Type of NSButton to "Toggle" and the image will automatically change to the alternate image/title. You can use a NSButton with type set to NSToggleButton and then

Change NSButton's background color on highlight

牧云@^-^@ 提交于 2019-12-05 06:37:55
I have an NSButton which I want to have a different background color when it's highlighted than when it's not (transparent on not highlighted, if that makes any difference). At present, I have the following code [view setWantsLayer:YES]; NSButton* button = [[NSButton alloc] initWithFrame:CGRectMake(0, 0, 100, 100)]; [button setBordered:FALSE]; [(NSButtonCell*)[button cell] setHighlightsBy:NSChangeBackgroundCellMask]; [view addSubview:button]; This will change the background to the default window background color on click. If I remove NSChangeBackgroundCellMask the background goes away. Is