How to update or redraw NSMenuItem while it is being displayed
How to update or redraw NSMenuItem while it is being displayed
- Subject: How to update or redraw NSMenuItem while it is being displayed
- From: Z Rosen <email@hidden>
- Date: Tue, 9 Mar 2004 17:50:13 -0500
I have an NSStatusItem with an NSMenu. The menu is populated in-code
with NSMenuItems that show the status of wireless devices.
I do NOT want to have to poll the devices continuously so I am using
NSMenu's menuNeedsUpdate to send a request to each device when the user
clicks the menu. However, the devices communicate asynchronously so
there is no way to return the new information to menuNeedsUpdate in a
timely fashion.
Here's some pseudo code to help:
Device:AskForStats {
SendStatusRequestToDevice()
}
Device:DataReceived {
self.statsdata = data
// Tell Menu or MenuItem to redraw self?
}
Menu:menuNeedsUpdate {
for each Device in devices {
Device.AskForStats()
self.addItem(Device.statsdata)
}
}
I have tried using NSMenu's itemChanged to tell the menu to redraw but
this only updates the item the next time the menu is clicked. Is there
a way to change the menu item and have the changes show up immediately?
Is this possible or is it forbidden by UI guidelines?
Thanks for any help you can give.
-ZR
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.