Search Results

Search found 9 results on 1 pages for 'nsstatusitem'.

Page 1/1 | 1 

  • NSStatusItem (cocoa) location on screen

    - by Craig
    I am trying to get the on screen location of an NSStatusItem so that I can perform a click on that area via code like below. I am doing this so that my users can press a hotkey to see the menu. event = CGEventCreateMouseEvent(NULL, kCGEventLeftMouseDown, newLocation, kCGMouseButtonLeft); CGEventPost(kCGHIDEventTap, event); CFRelease(event); Does anyone know of a way to get the location?, I have been trying ideas and searching for days and have found several ideas but none of them seem to work in leopard/snow leopard The NSStatusItem is using an NSMenu not a custom view.

    Read the article

  • Custom NSStatusItem with custom view - Use NSWindow, NSView, custom NSMenuItem?

    - by Luc
    I'm trying to create a LSUIElement app that behaves like Spotlight, CoverSutra and other apps of that type. I managed to create a custom NSStatusItem, which popups up an NSWindow but the problem is that the app that currently has focus will the focus to my custom NSWindow. I've based myself on Matt Gemmell's example (http://mattgemmell.com/2008/03/04/using-maattachedwindow-with-an-nsstatusitem) For example, if you're in Safari and click on the Spotlight icon, the current Safari window does not gray out and keeps focused. When you press ESC in Spotlight, the focus is back to the Safari window. I haven't managed to do this with my custom NSWindow. I have to click back on a window to set focus back to it. So I'd like to know which route to go to achieve this. Is the solution a NSWindow, NSPanel, NSMenu with a custom NSMenuItem?

    Read the article

  • How do I use an indeterminate status indicator as the image for an NSStatusItem?

    - by abrahamvegh
    I have an application that is an NSStatusItem. It has a few different modes, each of which require an external process to be launched, during which the icon is simply highlighted, and appears to be frozen. I want to use the -setImage method (or reasonable facsimile) to display something along the lines of a "spinner" commonly seen in web applications and all over OS X. Is there any native method for accomplishing this (e.g. some instance of NSProgressIndicator?) or must I manually display an animation by cycling through a set of images? In either case, how would I implement?

    Read the article

  • Custom NSView in NSMenuItem not receiving mouse events

    - by Dennis
    I have an NSMenu popping out of an NSStatusItem using popUpStatusItemMenu. These NSMenuItems show a bunch of different links, and each one is connected with setAction: to the openLink: method of a target. This arrangement has been working fine for a long time. The user chooses a link from the menu and the openLink: method then deals with it. Unfortunately, I recently decided to experiment with using NSMenuItem's setView: method to provide a nicer/slicker interface. Basically, I just stopped setting the title, created the NSMenuItem, and then used setView: to display a custom view. This works perfectly, the menu items look great and my custom view is displayed. However, when the user chooses a menu item and releases the mouse, the action no longer works (i.e., openLink: isn't called). If I just simply comment out the setView: call, then the actions work again (of course, the menu items are blank, but the action is executed properly). My first question, then, is why setting a view breaks the NSMenuItem's action. No problem, I thought, I'll fix it by detecting the mouseUp event in my custom view and calling my action method from there. I added this method to my custom view: - (void)mouseUp:(NSEvent *)theEvent { NSLog(@"in mouseUp"); } No dice! This method is never called. I can set tracking rects and receive mouseEntered: events, though. I put a few tests in my mouseEntered routine, as follows: if ([[self window] ignoresMouseEvents]) { NSLog(@"ignoring mouse events"); } else { NSLog(@"not ignoring mouse events"); } if ([[self window] canBecomeKeyWindow]) { dNSLog((@"canBecomeKeyWindow")); } else { NSLog(@"not canBecomeKeyWindow"); } if ([[self window] isKeyWindow]) { dNSLog((@"isKeyWindow")); } else { NSLog(@"not isKeyWindow"); } And got the following responses: not ignoring mouse events canBecomeKeyWindow not isKeyWindow Is this the problem? "not isKeyWindow"? Presumably this isn't good because Apple's docs say "If the user clicks a view that isn’t in the key window, by default the window is brought forward and made key, but the mouse event is not dispatched." But there must be a way do detect these events. HOW? Adding: [[self window] makeKeyWindow]; has no effect, despite the fact that canBecomeKeyWindow is YES.

    Read the article

  • LSUIElement behaves inconsistently with activateIgnoringOtherApps

    - by iconmaster
    Specifically, it behaves inconsistently regarding text field focus. I have an LSUIElement popping up a status menu. Within that menu there is a view containing a text field. The text field needs to be selectable -- not necessarily selected by default, but whichever. When the status item is clicked, it triggers [NSApp activateIgnoringOtherApps:YES]; And it works, about half the time.* The other half the status menu seems to consider itself "in the background" and won't let me put focus on the text field even by clicking on it. (I know the status item click-trigger is firing b/c there's an NSLog on it.) Is this a bug in the way Apple handles these status items, or am I mishandling activateIgnoringOtherApps? *In fact, it seems to fail only the first time after another app is activated. After that it works fine. The complete snippet: -(void)statusItemClicked:(id)sender { //show the popup menu associated with the status item. [statusItem popUpStatusItemMenu:statusMenu]; //activate *after* showing the popup menu to obtain focus for the text field. [NSApp activateIgnoringOtherApps:YES]; }

    Read the article

  • NSTableView and NSSearchField in an NSView, which is the outlet of an NSMenuItem, don't work

    - by Koning Baard XIV
    I'm having an NSView, which is set as the view: outlet of an NSMenuItem. The view contains an NSTableView (inside an NSScrollView) and an NSSearchField. The NSMenu is shown when the user clicks a specific NSStatusItem. When I launch the application from Xcode (Build and Run), the controls behave well, but whenever I launch it from the Finder (like the users would), they don't work and don't take any focus. My application is an LSUIElement. Can anyone help me out? Thanks.

    Read the article

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

    - by Frank R.
    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 "Preferences..." should bring up an NSWindow with the preferences. The first thing that doesn't seem to work is that the Window does not get ordered in at the front, but appears behind all other application windows. I tried to fix this by calling [[NSApplication sharedApplication] activateIgnoringOtherApps: YES] but that didn't work. After a while I figured out that the menu is blocking the message to the run loop from being sent, so I wrote another method on the MainController and sent the message with a delay: [self performSelector:@selector(setFront:) withObject: [preferencesController window] afterDelay:1.0]; -(void)setFront: (id) theWindow { [[NSApplication sharedApplication]activateIgnoringOtherApps:YES]; [theWindow orderFrontRegardless]; [theWindow makeKeyWindow]; [[NSApplication sharedApplication] activateIgnoringOtherApps:YES]; } Note the send-every-possible-message-to-make-it-do-what-it-should-be-doing-approach. This works, kind-of, the window is brought to the front on top of all other windows from all apps, BUT most of the time it isn't active, meaning it's title bar is greyed out. Clicking on the title bar won't make the window active either. Clicking INSIDE of the window will make it active!? This all didn't seem to be a problem in Leopard; just calling activateIgnoringOtherApps and making the window key seemed to work just fine. In Snow Leopard there is a new API designed to replace LSUIElement that is supposed to emulate its behaviour: http://developer.apple.com/mac/library/releasenotes/cocoa/appkit.html I've played around with that, but it's SL-only and I haven't been able to get LSUIElement being set. Any help would be greatly appreciated!

    Read the article

  • Mac OS X Status Bar Application - Hiding it from Cmd/Alt menu?

    - by Moddy
    I'm trying to whip up a simple little Status Bar Application in Obj-C/Cocoa. So I have done it pragmatically - declaring an NSStatusItem, adding it to the NSStatusBar and then giving it a NSMenu object. A bit like this... NSStatusBar *bar = [NSStatusBar systemStatusBar]; theItem = [bar statusItemWithLength:NSVariableStatusItemLength]; [theItem retain]; [theItem setTitle: NSLocalizedString(@"Tablet",@"")]; [theItem setHighlightMode:YES]; [theItem setMenu:theMenu]; (Example taken from "Status Bar Programming Topics", Apple Documentation) Now ideally, I'd like this application to run and not be accessible from the CMD/ALT window changing "menu" (for lack of a better word), I've seen applications do it before and would like that really. The idea is I just want it to be accessible from every window, whilst not having its own NSMenu on the status bar, and whilst not being able to have it as the active application ( - so its not able to take over the whole Status Bar, and its not able to be seen through CMD/ALT) Additionally, I was wondering if the StatusBarItem supports the ability to drag-n-drop an item onto it? I'm not sure if thats a limitation of the NSStatusBar though. I've read up on deamons and agents, but that seems far too low level/over kill for such a simplistic app! Cheers in advance!

    Read the article

1