Bug 317069 - MenuListeners not firing for Dock menu
Summary: MenuListeners not firing for Dock menu
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.6   Edit
Hardware: PC Mac OS X
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Scott Kovatch CLA
QA Contact: Silenio Quarti CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-16 12:31 EDT by Prakash Rangaraj CLA
Modified: 2019-09-24 13:57 EDT (History)
3 users (show)

See Also:


Attachments
Patch to Snippet 336 (2.39 KB, patch)
2010-06-21 04:03 EDT, Prakash Rangaraj CLA
no flags Details | Diff
Fix to call menuWillOpen (732 bytes, patch)
2010-06-21 16:24 EDT, Scott Kovatch CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Prakash Rangaraj CLA 2010-06-16 12:31:32 EDT
I tried attaching menu listeners to the Dock menu (TaskItem.setMenu), but they are never fired. Not sure of whether it is a bug/limitation of Dock Menus
Comment 1 Scott Kovatch CLA 2010-06-18 19:46:51 EDT
This works fine for me with 3.6 Cocoa. Can you post a sample app that isn't working?

I modified Snippet336 to create a menu and added it to the TaskItem returned from getTaskBarItem().
Comment 2 Prakash Rangaraj CLA 2010-06-21 04:03:13 EDT
Created attachment 172308 [details]
Patch to Snippet 336

I've added SelectionListener and MenuListener. SelectionListener is fired, but MenuListener isn't
Comment 3 Scott Kovatch CLA 2010-06-21 12:19:12 EDT
(In reply to comment #2)
> I've added SelectionListener and MenuListener. SelectionListener is fired, but
> MenuListener isn't

Thanks -- now that I re-read the description it's obvious that was what you were describing in the first place! I'll have a look.
Comment 4 Scott Kovatch CLA 2010-06-21 13:30:14 EDT
The dock menu is a strange animal because the application delegate provides a callback with an NSMenu, but the actual NSMenu doesn't get used. The normal menuDidOpen notification doesn't fire.

However, it looks like the menu is requested every time you right-click on the dock, so we can call menuDidOpen just before returning the menu. That will send SWT.Show and you'll get the menuShown() callback.

Is that enough for now? I can't find a notification for the menu being closed, so we may not be able to send that.
Comment 5 Scott Kovatch CLA 2010-06-21 16:24:34 EDT
Created attachment 172367 [details]
Fix to call menuWillOpen

Change adds call to menu.menuWillOpen before we return it to the dock. There's no notification that the dock closed, however, so I don't think we can report it.
Comment 6 Scott Kovatch CLA 2010-06-28 13:09:29 EDT
Silenio, what do you think about this? I think it's better than nothing -- I verified we get asked for the dock menu every time you click on the dock, so we can always send the Show event, but not the Hide event.
Comment 7 Silenio Quarti CLA 2010-06-28 17:14:25 EDT
We cannot provide this API for cocoa only. We need to see if it is possible to implement it on Windows7 as well. And I am not sure the API makes sense since the task menu can be shown even if the application is not running. Note that this is only implemented on Windows7 right now, but it can be done on cocoa as well (NSDockTilePlugIn).

So the menu content (items, text, image) has to be static. The main use of SWT.Show/SWT.Hide is for changing the menu dynamically (before the menu is shown).

Prakash, what do you want to do with SWT.Show/SWT.Hide?
Comment 8 Scott Kovatch CLA 2010-06-28 17:41:14 EDT
(In reply to comment #7)
> We cannot provide this API for cocoa only. We need to see if it is possible to
> implement it on Windows7 as well. And I am not sure the API makes sense since
> the task menu can be shown even if the application is not running. Note that
> this is only implemented on Windows7 right now, but it can be done on cocoa as
> well (NSDockTilePlugIn).
> 
> So the menu content (items, text, image) has to be static. The main use of
> SWT.Show/SWT.Hide is for changing the menu dynamically (before the menu is
> shown).

Oh, I assumed this was something missing on Cocoa, but it looks like I misunderstood the purpose of TaskBar and TaskItem.

NSDockTilePlugin is an interface for a bundle included in your app that the dock will call when the app is in the dock but not running. I'm not sure that's practical for the SWT.
Comment 9 Prakash Rangaraj CLA 2010-06-29 01:03:43 EDT
(In reply to comment #7)

> Prakash, what do you want to do with SWT.Show/SWT.Hide?

    I was experimenting of contribution of menu items thru the Command Framework. If it works well, we could possibly accept contributions to a uri like "menu:org.eclipse.ui.taskBar". Of course this can happen only when the application is running, but that should be good enough.
Comment 10 Lars Vogel CLA 2019-09-24 13:57:48 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.