appkit

Force NSMenu (nested submenu) update for Main Menu of Cocoa App

I have some submenu inserted as Window item submenu of Main Menu I have an instance of my object (let's assume its class name is MenuController) inherited from NSObject and supports 2 from NSMenuDelegate methods: – numberOfItemsInMenu: – menu:updateItem:atIndex:shouldCancel: This instance added as Blue-Object into NIB for awaking at run...

Responder chains for nil-targeted actions and events

Hi, Do events (i.e. -keyDown: and -keyUp:) follow the same responder chain as nil-targeted actions? Thanks. ...

NSMenuItem's value binding with BOOL

Hi, I am having some issues binding an NSMenuItem's "value" binding to a BOOL. I simplified the problem to this: 1) The menu item must call the action method that changes the value of the BOOL otherwise it doesn't work (i.e. if an NSButton calls a method that changes the value of the BOOL then the menu item won't update) 2) Even if ...

How to get height for NSAttributedString at a fixed width

I want to do some drawing of NSAttributedStrings in fixed-width boxes, but am having trouble calculating the right height they'll take up when drawn. So far, I've tried: Calling - (NSSize) size, but the results are useless (for this purpose), as they'll give whatever width the string desires. Calling - (void)drawWithRect:(NSRect)rect o...

How to relayout content of NSTextView so that my tab characters are drawn with width of 4 characters

I'm working with an NSTextView and one of the requirements I have is that a tab character, '\t', shall have the same width as four spaces. So the text-content would look like this: AAAA AAAA - 1 tab AAAA - 4 spaces And this is how I accomplish this: // done when NSTextView first loaded and when // delegate's textDidBeginEdit...

Python's AppKit and ObjectiveC Delegates

AppKit allows Python programs on a Mac to use ObjectiveC classes. I am not very familiar with ObjectiveC, but I want to access the NSSound class using AppKit in order to create an audio player. My player should perform some action, such as loading the next item from the playlist, when the current audio finishes playing. There is a metho...

NSSegmented Control Not Selecting

I have an NSSegmentedControl with the textured rounded style, and with the selection mode set to 'any'. The problem is that it is treating it like select none. When I switch the style to capsule, it works correctly. I am using this in a toolbar, although I have tested this in a view (on two different computers) as well and it behaves ...

NSTextField and hidden property

Hi, I have an NSTextField that I hide when the user presses a button. I hide the text field using [textField setHidden:YES]; The problem is that is the user is typing in the text field (i.e. the text field is first responder) and the user presses the return key (which is the key equivalent for the button that hides the text field) the u...

Zooming in an NSView

Hi, I have an NSView in which the user can draw circles. These circles are stored as an array of NSBezierPaths, and in drawRect:, I loop through the array and call -stroke on each of the paths. How do I add a button to zoom in and out the NSView? Just change the bounds of the view? Thanks. ...

Keeping window of another application active while still receiving mouse events from another app's window?

Is there a way to have my app's window receive keyboard and/or mouse events (i.e. user clicking on window's buttons) while still retaining focus to another, unrelated app? I've tried configuring my window at different levels, including [myWindow setLevel:NSPopUpMenuWindowLevel] to no avail. ...

Cocoa AppKit - Dismissing a modal window (i.e. popup or contextual menu) and pressing the button currently hovered above

Basically I want to create the effect of that provided in the system's menu bar. A user presses on one of the menu headings, and as he moves across the different headings, the menus open up automatically. The snag is that if I open a pop-up menu for a button, the user has to click again to dismiss it. The entire runloop is on hold as I ...

EXC_BAD_INSTRUCTION (SIGILL) at random during use of app. Bug in AppKit?

I'm currently testing a new version of an app of mine on OSX 10.5 An user reported some weird crashes during use of the application, sadly not reproducible by me. At first sight it seems to happen randomly, once he had the crash while opening an NSOpenPanel and once during focusing an NSTextField and once during NSView switch in a parent...

NSTextField and backgrounded application

Hello, I'm building an application that uses a NSStatusItem and run in the background. The problem I'm running into is entering text into a NSTextField. I've got a menu item in my NSStatusItem which: [NSApp activateIgnoringOtherApps:YES] [prefPanel makeKeyAndOrderFront:nil] It shows up fine, but when I try to enter text into the NST...

Getting better at drawing in code for Cocoa?

Hi, What are some suggested "paths" for getting better at drawing in code in Cocoa? I think at this point, that's my biggest weakness. Is drawing in code something general, or Cocoa-specific? Thanks! - Jason ...

Creating a NSView from a CGPath

I have a CGPath and I want to draw it once to a NSView. Seems relatively simple but I haven't found a way in AppKit (non iphone). ...

dismissPopUp is not recognized

Assuming button1 is an NSPopUpButton Assuming menu attached to button1 is displayed and being tracked. [[button1 cell] dismissPopUp] --- dismissPopUp is not recognized. Why is the dismissPopUp method not recognized? Thanks ...

Snow Leopard & LSUIElement -> application not activating properly, window not "active" despite being "key"

Hi, I'm running into a few problem with a background application that uses LSUIElement=1 to hide its dock item, menu bar and prevent it from appearing in the Command-Tab application switcher. It seems to be a Snow Leopard only problem. The application places an NSStatusItem in the menu bar and pops up a menu when clicked on. Selecting...

Purpose of CALayer?

Hi, I'm slightly used as to what the purpose of CALayer's existence is. Why not just put the properties in a UIView? Thanks. ...

Is it possible to get an NSView to pass rightMouseDown: to the next responder without subclassing?

I have a view which contains a few subviews: mainView subViewA subViewB SubViewC mainView is an NSView constructed from a nib and is controlled with an NSViewController subclass. The subviews are standard views such as NSTextField and NSImageView and are configured to be non-editable. I want mainView to receive rightMouseD...

Prevent selecting all tokens in NSTokenField

Is there any way to prevent the NSTokenField to select everything when pressing the ENTER key or when making to the first responder maybe using the TAB key? ...