English 中文(简体)
NSMenu 模拟活动
原标题:NSMenu s mouse over event

我利用NSMenu和NSStatusItem长时间在地位酒吧展示习俗菜单:

statusItem = [[[NSStatusBar systemStatusBar] statusItemWithLength:18] retain]; [statusItem setImage:[NSImage imageNamed:@"myIcon"]]; [statusItem setMenu:myMenu]; [statusItem setHighlightMode:NO]; ...

It works fine by start clicking its image icon. But I noticed that apple s menu located on status bar can be triggered simple by mouse move over, like the airport menu, power menu, language menu and date/time menu. They are all auto pop up when you mouse walk over. How did they get it?

I have checked the "add tracking rect" for NSView with "mouseEntered" event, but things is not as difficult as that I think.

任何建议?

问题回答

我认为现状 项目不是一个支持的改变活动,但你可以确定现状。 项目,并推翻甚至支持 mo变活动的方法,就像此:

statusItem = [[[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength] retain];
  NSButton *nb = [[NSButton alloc] init]; 
  [nb setImage:image];
  [nb setAction:@selector(statusItemClick:)];  
  [_statusItem setView:nb];

here just an example to set a view to statusitem, if you want to support the mouse event , your view must extend same view and create NSTrackingArea and implement the moveMoved, mouseEntered and mouseExited methods (or whichever ones you want)





相关问题
better way of jquery mouseover?

I am trying to create an effect where if you hover over an img, the color of text will change below it. And also, when you mouseout, the color will change back to its original color. The page is: http:...

Possible/howto resize iframe on mouse focus?

I have two iframes next to each other at 50% width and am wondering if it s possible to resize one iframe to 80% when that iframe is moused over. Is it possible? If so, can someone post a small how-to ...

how to control popup with ruby on rails, mouse roll-over

I have an application where user can see a list of cells. For each cell the user can see two images of the cell as popup menu. The problem is that all images are downloaded when a list is selected and ...

Jquery mouseover/mouseout triggering inconsistently

I have two sortable lists, one being nested, with a mouse over effect on the li elements of the nested sortable list. My problem is that the mouseover and mouseout functions are being called ...

热门标签