Updating menulet icon creates multiple menulets!

Discussion in 'Mac Programming' started by varlos101, Sep 19, 2010.

  1. macrumors newbie

    Joined:
    Aug 19, 2010
    Location:
    Washington
    #1
    I'm creating an app that controls/connects to a 3G usb modem and right now I'm setting up the way that it reads the signal, but when it updates/sends the action it creates another menulet until my menu bar is full, how can I make it update the existing image?

    Here's how I'm doing it and it works good for the large images inside the main window. The reason the images are titled fivemenubars and such is because I already used fivebars elsewhere.
    Code:
    	if (calculatedSignal < -106) {
    		[statusItem setImage:(NSImage *)onemenubar];
    	}
    	else if (calculatedSignal < -98) {
    		[statusItem setImage:(NSImage *)twomenubars];
    	}
    	else if (calculatedSignal < -90) {
    		[statusItem setImage:(NSImage *)threemenubars];
    	}
    	else if (calculatedSignal < -82) {
    		[statusItem setImage:(NSImage *)fourmenubars];
    	}
    	else if (calculatedSignal > -82) {
    		[statusItem setImage:(NSImage *)fivemenubars];
    	}
    
     
  2. thread starter macrumors newbie

    Joined:
    Aug 19, 2010
    Location:
    Washington
    #2
    Nevermind, I figured out what went wrong... duh... I hate programming at 1 AM. I put the code for the whole menu (including the initialization!) under the action to update the signal. So it changes the icon for the menu, but it also re-initializes each time!

    Fixed it and now it works as it should...
     

Share This Page