PDA

View Full Version : Updating menulet icon creates multiple menulets!




varlos101
Sep 19, 2010, 02:22 AM
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.

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];
}



varlos101
Sep 19, 2010, 02:27 AM
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...