nsbutton

How can I vertically align my status bar item text?

落花浮王杯 提交于 2019-12-05 02:34:13
Left one on the picture is the date and time from Apple and one is my application one. As you may see the text of my application appears lower than the Apple one. Which doesn't look pretty. How can this be resolved? self.statusBarItem.image = nil self.statusBarItem.button?.imagePosition = .NoImage self.statusBarItem.button?.title = "Sun 5 Jun 13:35" Tarvo Mäesepp You could do it in offset. You cannot do it like this since it needs to be done on the status item button bar. button.frame = CGRectMake(0.0, 0.5, button.frame.width, button.frame.height) I wanted to make a quick addition to this.

Drag a button in OSX 10.8 SDK/objective-c

一曲冷凌霜 提交于 2019-12-05 02:04:38
问题 I started using objective-c today in order to develop an app for OSX (mountain lion). I have a bunch of buttons that I would like to drag them into some other object, for instance a text field. I followed the tutorials on apple's dev site, but I wans't able to get the drag part working (the drop part works, for instance, I can drag a file from finder into a text file and show its path). I started by creating a NSButton subclass: @interface mp3OCDDraggableButton : NSButton and implemented the

NSButton's images lose transparency on selection

妖精的绣舞 提交于 2019-12-05 00:10:01
问题 I have edited some NSButtons in my Mac OS X application and set a custom image to them. The images are in png format with transparency. When I select a button, the background of the image goes white. Does anyone know of a way to fix this? 回答1: The issue was that I was customising a 'Bevel' button. I changed the button bezel to 'Square' and changed the button type to 'Momentary Change'. Hope this helps some people in the future! 来源: https://stackoverflow.com/questions/4801418/nsbuttons-images

NSButton background transparent after getting focus

我的未来我决定 提交于 2019-12-04 22:02:22
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, which I found scattered around the web: optionsButton.setButtonType(.MomentaryChangeButton)

NSButton white background when clicked

て烟熏妆下的殇ゞ 提交于 2019-12-04 12:07:26
问题 When creating Cocoa bevel button with custom image and alternate image I'm having a strange behavior. In the pressed state the button background becomes white. I'm adding the button as subview of a transparent window (HUD window). I'm trying every technique that I know: NSButton *closeButton = [[NSButton alloc] initWithFrame:NSMakeRect(0.0, 0.0, 30.0, 30.0)]; [closeButton setFrameOrigin:NSMakePoint(0.0, 0.0)]; [closeButton setImagePosition:NSImageOnly]; [closeButton setAction:@selector

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

北战南征 提交于 2019-12-04 07:48:34
I need to programatically create and position a button in a Mac OS X Cocoa application. Any help would be appreciated... To possition button You need to change the button's origins x and y. Look at the sample code which I wrote below and comments. You can do it like this: -(void)awakeFromNib { //Start from bottom left corner int x = 100; //possition x int y = 100; //possition y int width = 130; int height = 40; NSButton *myButton = [[[NSButton alloc] initWithFrame:NSMakeRect(x, y, width, height)] autorelease]; [[windowOutlet contentView] addSubview: myButton]; [myButton setTitle: @"Button

Cocoa forControlEvents:WHATGOESHERE

南笙酒味 提交于 2019-12-03 22:34:46
问题 In Cocoa/Objective-C if I have created a button programmatically, what do I put in for my control event? [btnMakeChar addTarget:self action:@selector(makeChar:) forControlEvents:WHAT GOES HERE?]; In iOS you can write it like so forControlEvents: UIControlEventTouchUpInside I can't find anything to show what I would use for just cocoa, not cocoa touch 回答1: I'm not sure if I understand you correctly, but if you're programming a Mac, [theHappyButton setTarget:self]; [theHappyButton setAction:

Drag a button in OSX 10.8 SDK/objective-c

时光怂恿深爱的人放手 提交于 2019-12-03 16:59:29
I started using objective-c today in order to develop an app for OSX (mountain lion). I have a bunch of buttons that I would like to drag them into some other object, for instance a text field. I followed the tutorials on apple's dev site, but I wans't able to get the drag part working (the drop part works, for instance, I can drag a file from finder into a text file and show its path). I started by creating a NSButton subclass: @interface mp3OCDDraggableButton : NSButton and implemented the methods as described in: https://developer.apple.com/library/mac/#samplecode/CocoaDragAndDrop

NSButton's images lose transparency on selection

拟墨画扇 提交于 2019-12-03 16:04:00
I have edited some NSButtons in my Mac OS X application and set a custom image to them. The images are in png format with transparency. When I select a button, the background of the image goes white. Does anyone know of a way to fix this? The issue was that I was customising a 'Bevel' button. I changed the button bezel to 'Square' and changed the button type to 'Momentary Change'. Hope this helps some people in the future! 来源: https://stackoverflow.com/questions/4801418/nsbuttons-images-lose-transparency-on-selection

Simple mouseover effect on NSButton

拥有回忆 提交于 2019-12-03 08:42:48
问题 I am creating a custom NSButtonCell for a custom rendering. Now, I want to have different aspect depending if the mouse is over the button or not. How can I get this information? Thanks and regards, 回答1: Here is i have created and worked for me perfectly... Step 1: Create the Button with tracking area NSButton *myButton = [[NSButton alloc] initWithFrame:NSMakeRect(100, 7, 100, 50)]; [myButton setTitle:@"sample"]; [self.window.contentView addSubview:myButton]; // Insert code here to initialize