Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

varlos101

macrumors newbie
Original poster
Aug 19, 2010
10
0
California
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];
	}
 
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...
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.