| Summary: | [Mac] E3.x's CocoaUIEnhancer and e4's CocoaUIHandler needlessly disable the Services menu | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Brian de Alwis <bsd> | ||||||||||||||||
| Component: | SWT | Assignee: | Scott Kovatch <skovatch> | ||||||||||||||||
| Status: | RESOLVED FIXED | QA Contact: | Silenio Quarti <Silenio_Quarti> | ||||||||||||||||
| Severity: | normal | ||||||||||||||||||
| Priority: | P3 | CC: | lshanmug, prakash, skovatch | ||||||||||||||||
| Version: | 3.6 | ||||||||||||||||||
| Target Milestone: | 3.7 M6 | ||||||||||||||||||
| Hardware: | Macintosh | ||||||||||||||||||
| OS: | Mac OS X | ||||||||||||||||||
| Whiteboard: | |||||||||||||||||||
| Bug Depends on: | 329216 | ||||||||||||||||||
| Bug Blocks: | 327384 | ||||||||||||||||||
| Attachments: |
|
||||||||||||||||||
|
Description
Brian de Alwis
Merely enabling the menu doesn't help. If you select a text, you expect text related services to be enabled in the Services (like 'TextEdit->New Window containing selected text' should be enabled) Unless we contribute/access the Services menu, I don't see a point in enabling it. (In reply to comment #1) > Merely enabling the menu doesn't help. If you select a text, you expect text > related services to be enabled in the Services (like 'TextEdit->New Window > containing selected text' should be enabled) Actually, enabling it does exactly that. For example, I frequently select text and then use the "Open URL" and "Make New Sticky Note" services. You can't do this in an Eclipse app since the Services menu is disabled. After removing the questionable services-disbling code, these services (and others) work fine. > Unless we contribute/access the Services menu, I don't see a point in enabling > it. We're currently preventing the *user* from accessing it. Created attachment 178071 [details] Patch v01 (In reply to comment #2) > (In reply to comment #1) > > Merely enabling the menu doesn't help. If you select a text, you expect text > > related services to be enabled in the Services (like 'TextEdit->New Window > > containing selected text' should be enabled) > > Actually, enabling it does exactly that. I'm trying to enable the Services menu using the attached patch. When I have some text selected in the text editor none of the services are enabled. How are you enabling the Services menu? (In reply to comment #3) > I'm trying to enable the Services menu using the attached patch. When I > have some text selected in the text editor none of the services are enabled. > How are you enabling the Services menu? Huh. I think that must be an issue with StyledText widgets. I've been doing my testing with an e4 RCP app, where I used plain SWT Text widgets, and it works fine. But I then tried against R3.6 and, when selecting text entered into a text editor or the JDT/Debug's Display view, there are no applicable services. If you use a normal text field (e.g., the filter box in the preferences) then the full suite of text services are available. (In reply to comment #4) > Huh. I think that must be an issue with StyledText widgets. Yup! Got it now. It works when normal text widgets have selection. I'm cc-ing Scott & Lakshmi. They are the Cocoa experts. StyledText is a Composite and therefore doesn't use an NSTextView. To get Services menu requests we need to implement three methods: validRequestorForSendType:(NSString *)sendType returnType:(NSString *)returnType writeSelectionToPasteboard:types: (NSServicesRequests protocol) readSelectionFromPasteboard: (NSServicesRequests protocol) Moving this into SWT. This would be a very useful thing to support, so I'm going to try to get to this for 3.7. Created attachment 178096 [details]
Patch v02 (platform-ui)
Alternative patch: just get rid of kServicesMenuItem and its uses.
Created attachment 178097 [details]
Patch v02 (e4)
Equivanelt patch for e4 codebase
Please don't do this. I have a fix for the root problem, which is to add the methods I mentioned in comment #6. (In reply to comment #7) > Created an attachment (id=178096) [details] > Patch v02 (platform-ui) > > Alternative patch: just get rid of kServicesMenuItem and its uses. Created attachment 178206 [details]
Fix to enable Services for StyledText
Prakash, to completely fix this we need to stop disabling the Services menu. Cocoa completely controls whether the menu can be enabled or disabled.
This patch implements the three methods needed to pick up the current selection from a StyledText and pass it to the selected service. Services that read the text and do something with it work fine. I'm still looking for a service that writes something back to the view.
(In reply to comment #10) > Prakash, to completely fix this we need to stop disabling the Services menu. > Cocoa completely controls whether the menu can be enabled or disabled. That's exactly the purpose of the two patches you just marked as obsolete ;-) > This patch implements the three methods needed to pick up the current selection > from a StyledText and pass it to the selected service. Services that read the > text and do something with it work fine. I'm still looking for a service that > writes something back to the view. This site has several URL shortners (e.g., bit.ly, is.gd) that both reads and writes back: http://taotek.com/products.php (In reply to comment #11) > (In reply to comment #10) > > Prakash, to completely fix this we need to stop disabling the Services menu. > > Cocoa completely controls whether the menu can be enabled or disabled. > > That's exactly the purpose of the two patches you just marked as obsolete ;-) I'm sorry -- I completely misread the patch. I'll fix that. :-) I also found a way to wrap a URL shortener into a service, so I'll attach that for testing. Created attachment 178207 [details]
Corrected fix
Found a bug when writing the string back into the Canvas.
Created attachment 178208 [details]
URL shortener for testing
Here's an Automator service I wrote that calls a URL shortener on the selected text.
I will commit this on Tuesday and then assign the bug over to Prakash for the platform-ui change. After review it was pointed out that referring to StyledText directly from the native SWT components is a no-no, so I'm going to have to rework this a bit. I can use the accessibility API to get the current selection but there's no way to set it until we implement IAccessible2EditableText support. (bug 324005) The alternative is to implement this at the UI level in the CocoaUIEnhancer, which is above the SWT in the architecture hierarchy. Then it could do the 'instanceof StyledText' check, but that would involve adding the Cocoa methods to SWTCanvasView on the fly. In any event, you definitely should un-disable the services menu. Patch v02 committed to both codebases. Created attachment 181025 [details]
Fix using accessibility
Patch uses accessibility APIs to get and set the selected text. I'll mark this fixed when StyledText implements AccessibleEdtableTextListener.
Fixed > 20101015, but waiting on StyledText change. 329216 is now fixed, so this bug can now be marked as fixed. |