| Summary: | Add API to access the application menu (Mac) and system menu (win32/gtk) | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Scott Kovatch <skovatch> | ||||||||||||||||||
| Component: | SWT | Assignee: | Scott Kovatch <skovatch> | ||||||||||||||||||
| Status: | RESOLVED FIXED | QA Contact: | Silenio Quarti <Silenio_Quarti> | ||||||||||||||||||
| Severity: | enhancement | ||||||||||||||||||||
| Priority: | P3 | CC: | bsd, eclipse.felipe, prakash, pwebster, tom.schindl | ||||||||||||||||||
| Version: | 3.6 | Flags: | Silenio_Quarti:
review+
|
||||||||||||||||||
| Target Milestone: | 3.7 M6 | ||||||||||||||||||||
| Hardware: | All | ||||||||||||||||||||
| OS: | Mac OS X | ||||||||||||||||||||
| Whiteboard: | |||||||||||||||||||||
| Bug Depends on: | |||||||||||||||||||||
| Bug Blocks: | 153761, 337482 | ||||||||||||||||||||
| Attachments: |
|
||||||||||||||||||||
|
Description
Scott Kovatch
Created attachment 182863 [details]
Cocoa implementation
Cocoa implementation implementing Menu.findItem, Display.getAppMenu(), MenuItem.get/setId. I'll attach a test case shortly.
Created attachment 182865 [details]
Cocoa implementation
Small fix -- not comparing NSMenuItems properly.
Created attachment 182921 [details]
Modified test case
This snippet uses the new API to modify the application menu and listen for selections on application menu items. It also blocks the Hide and Hide Others as a demonstration.
Scott,
The API looks good. (See Bug# 153761) Is this bug targeted for M4?
I hope to get this into 3.7m4. The findItem/getId/setId API is trivial on all other platforms. (moving to Cocoa so I don't lose it.) Created attachment 184428 [details]
Implementation for non-cocoa platforms
setId/getId, findItem for all other platforms.
M4 is coming up next week, so it will be reviewed for m5. Is this going into M5? Waiting on review -- would be good to get this in for 3.7. Created attachment 189059 [details]
Cocoa implementation
Updated after code review. Greatly simplified creating placeholder MenuItems that correspond to application menu items. Also sync item text and accelerator with existing native values.
Created attachment 189060 [details]
Implementation for non-cocoa platforms
Updated after comments from review. Added getAppMenu for all other platforms.
Brian - This be interesting for our e4.cocoa.renderer stuff (In reply to comment #12) > Brian - This be interesting for our e4.cocoa.renderer stuff Definitely! The Cocoa support is significantly trimmed down and now generalizes to other platforms. Scott, do consumers need to do to embed the application name in the appropriate menu items? E.g., "About Eclipse" or "Quit Eclipse"? Or are these items populated by the Display.setAppName()? (In reply to comment #13) > Scott, do consumers need to do to embed the application name in the appropriate > menu items? E.g., "About Eclipse" or "Quit Eclipse"? Or are these items > populated by the Display.setAppName()? As long as you call setAppName before you create the Display they will be populated for you automatically. The application menu is created during creation of the Display. Created attachment 190280 [details] implementation for all platforms This is the final API. We decide to keep this new API consistent with other methods in display that return system-provide resources (getSystemFont(), getSystemColor(), etc). The new API is Display.getSystemMenu(). We plan to add Shell.getSystemMenu(), but this might not happen for 3.7. We are also renaming Display.getAppMenuBar() to Display.getMenuBar(). The original name for this was Display.getAppMenu(), but we would be adding a new concept to the toolkit API that is not necessary ("App"). See bug#338825. I also changed the constants in SWT from MENU_ITEM_* to ID_*. Shorter names and they IDs after all. Created attachment 190283 [details]
testcase
updated testcase
Menu.findItem() is also not necessary. Application can easily get the appropriate item using Menu.getItem()/Menu.getItems() and MenuItem.getID(). Added bug#338831 to address the remaining API in Shell (Shell.getSystemMenu()). Fixed > 20110303. Thanks Scott. (In reply to comment #15) > Created attachment 190280 [details] > implementation for all platforms > > This is the final API. We decide to keep this new API consistent with other > methods in display that return system-provide resources (getSystemFont(), > getSystemColor(), etc). The new API is Display.getSystemMenu(). We plan to > add Shell.getSystemMenu(), but this might not happen for 3.7. > We are also renaming Display.getAppMenuBar() to Display.getMenuBar(). The > original name for this was Display.getAppMenu(), but we would be adding a new > concept to the toolkit API that is not necessary ("App"). See bug#338825. Fair enough. 'Display' === 'application', certainly on Cocoa and Carbon, so that makes sense. I will update my EclipseCon talk, since I know it has the old names. Thanks for getting this checked in! I know this was a pain point for many Mac developers. |