Whenever I'm like surfing on the web and I highlight a bunch of text, I see a "New TextWrangler Document with Selection" item on the contextual menu.
How do I replicate this functionality with my app so that whenever a user selects text in any other application, he can see a "New (My App) Document with Selection" item in the contextual menu and upon clicking on it, it feeds the selected text into my app?
Update
To try to answer my own question, I followed the sample code here: http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/SysServices/Articles/providing.html
which implements a simple rot13 encryption service on highlighted text. but it ain't working.
Although my "Encrypt Text" appears in the system preferences menu like "New TextWrangler Document with Selection" as shown above, it doesnt actually appear in an application's services menu or right-click contextual menu when text is selected.
Can someone tell me why the sample code in apple's documentation is not working
#PeterHosey here it is, with NSRequiredContext too:
my app name is called "simpleEncrypt" and the message is exactly the same as the one copied from apple's services implementation guide.
- (void)simpleEncrypt:(NSPasteboard *)pboard
userData:(NSString *)userData error:(NSString **)error;
In the Info.plist for my Translate Text application, I'm using NSStringPboardType as the send type for each of its services.
The system-declared UTIs list says that the modern equivalent to that is public.utf8-plain-text, so try changing your service's send and return types to that.
If it works, it'd probably be a good idea to list all the plain-text variants. Those are listed there in the Uniform Type Identifiers Reference; they're the types that conform to public.plain-text.
You need to include an NSRequiredContext dictionary in your service dictionary that describes when the service is appropriate to enable. Until you do, it is disabled in all contexts by default. (I'm not sure why it still doesn't show up even after you enabled it, but this is a required first step.)
Related
For a custom language I created a CompletionContributor. Everything works fine. But I'm limited to the information I can display (only in the list or the bottom "advertisement" and only 1 line).
When trying to auto-complete on a java class name it will display more information on the selected line in a small side window. I would like to exploit that mechanism but I really don't know how it is done.
When looking at the options provided, I can use a custom LookupElementRenderer but there is no method in LookupElementPresentation related to the right window.
Any idea how it is done?
Are you referring to documentation popup which may be displayed if the corresponding setting (Setting->Editor->General->Code completion->Show the documentation popup in) is turned on?
If you want the feature to work for your language you have to use lang.documentationProvider extension point.
I am looking for a way to right click selected text and open it in my app. Eg. via OS X's third party share menu. But I can not find any references at Apple's.
Have a look at the apple docs SysServices for creating a service for you app.
The Docs take you through an example of how to set one up.
Once done you will need to go into System Preferences and Enable the service. Your users will also need to do that.
Here is a quick project that shows an adaption of the apple code.
Update:
Although I think the services work good enough. Creating a Share or Action Extension is possible.
This example uses the same Project as above. But I have added an App Action extension (Target) to it.
The template for the Action is not too hard to understand and it took me 5 minutes to do this quick example.
(So I am not saying everything is as it should be but it works)
For the Action Extension:
Follow the instructions here
Which basically is:
After you choose the extension point that makes sense for your app
extension, add a new target to your containing app. The easiest way to
add an app extension target is to use an Xcode template that provides
a target preconfigured for your extension point.
To add a new target to your Xcode app project, choose File > New >
Target. In the sidebar on the left side of the new target dialog,
choose Application Extension for iOS or OS X. In the pane on the right
side of the dialog, Xcode displays the templates you can choose
Do read the above docs to understand better of what you need to do.
Once you have added the Extension. You can actually run it straight away.
Xcode provides you an option to choose a test app to test it in i.e TextEdit.app and takes you through the whole process of temporarily enabling the Extension.
In this example, remember I chose an Action Extension which suited the App.
The App's function in life is to do a basic encryption of selected text and then display the result.
The App's Action Extension will do the same but instead of displaying it, it will replace the selected text with the encryption text.
All that was needed for me to do, was copy the encryption method from the main app, over to the Extension.
I did have to adjust a couple of things though. Namely the original code deals with a NSString, where as the Extension deals with a NSAttributedString.
The conversion I did works but styling attributes are lost. For this example that does not really matter.
An Action Extension does not use the Share contextual menu. It uses an Action menu.
To see the menu, select some text and the hover the cursor over the selected text. You then should see a discloser button on the left of the text.
Like this:
Click it and choose the Extension.
If you do not see it, go to the 'more' option. This will take you to the system preferences where you can grant access to the extension.
The documentation is mainly concerned about distributing the extension and App via the App store.
But you can code sign your App and extension and do a normal archive export.
From there, all should work ok with gatekeeper.
But again refer to the Docs for a fuller understanding.
Here is a link for the code signed app and also the new Project.
Encrypto2
Ektron 9 - steps to trigger issue ... we think:
Create new content folder
Edit folder properties
Smart Forms tab - untick inherit, and remove "Blank HTML"
The "new" menu on the folder now:
Does not show DMS Document as a menu item
Does not show Smart Form list as a pull-out sub menu.
Question
How do I get "Blank HTML" back into the smart form tab property in the folder
Why is this happening
Help!!
[Edited] Workaround
eGandalf gave the simple answer via Twitter (previously I had attempted a workaround of putting inheritance back on then resetting the tree): toggle the "Require Smart Forms" checkbox on the "Smart Forms" tab and the Blank HTML option will come back.
This is by design. When you remove the HTML option, note that it checks the "Require Smart Form" box (and, reciprocally, checking the Require Smart Form box removes the HTML option). That means that all other types, including PageBuilder, DMS documents, or HTML are now forbidden in this folder.
As a best practice, you shouldn't be mixing types in a folder anyway. A lot of people do, but that doesn't make it any more valid. If you've got a folder for Press Releases and you have a Press Release Smart Form, you shouldn't have any other type of content in that folder. The less you mix types, the less filtering you have to do either with the API or post-request via LINQ. As a result, you'll have a more consistently performing site.
In situations like this, where I want the DMS assets and the Smart Form content to a) both be searchable, b) both be managed by the same user/group and c) there's a strong connection between the two (e.g., Whitepaper information Smart Form + PDF asset download), I'll create a child folder and allow DMS assets there. In the Case Study example, the folder structure may look like this:
Content
Case Studies (Smart Form only)
Downloads (DMS Allowed)
In contrast, if I don't want the DMS assets to be independently searchable, I'll remove them from the Content folder entirely and place them in a separate, root-level, non-searchable folder called Resources or Downloads.
Because Blank HTML is a default (and ID 0), you might have to reassign it in the database.
My guess is that removing the Blank HTML option impacts DMS retrieval in the workarea specifically.
In this case, I'd reach out to support, I've never actually needed/wanted to do this.
Edit:
I dug a bit more to try and give you something to try.
You'll need to reinsert an xml_id into folder_to_xml_tbl.
insert into folder_to_xml_tbl VALUES(your_folder_id, 0, 1);
Ektron support have replied:
Hi ,
Engineering have advised that DMS documents are unstructured.
By forcing all content to be structured content, it disallows raw html as well as dms assets and only allows documents with structure to be created
In any reply please include the case number in the subject line.
To open a new case email uksupport#ektron.com or use the support request form at http://www.ektron.com/Resources/Support/Contact/
I have tried many objects in Xcode's object library, but I can't seem to find the correct objects.
What I am trying to do is create a log for my app, for development purposes, but also for any future users who just feel like having a log. I don't want to use NSLog(NSString). I need an Obj-C equivalent of Java's javax.swing.JTextArea that has the following properties:
1. can be contained in a scroll pane (and how do I do this)
2. can be set to un-editable (Java equivalent of myTextArea.setEditable(false))
3. (in code) can receive \n as "new line" (shouldn't be a problem)
Does this exist, and if not, how can I create something similar (for example covering a text area with a layer)?
Thanks
Cocoa's NSTextView class fits this perfectly. It can be found in the object library as "text view". It can be set to non-editable in the properties inspector and can receive "\n" as a new line. It already has scroll bars.
I have an Eclipse RCP application. I have created an Editor. There are few context menu (default), when I right click on the Editor. I have not created these menus.
Please let me know, How to remove the context menu of the Editor?
It needs different approach by which editor you extends.
Let me know What you extends, than I can answer more efficient one.
In general way:
IWorkbenchParSite#registerContextMenu(...) will be used, So find where calls that, override it. It is not recommend. Because by doing this, Menu Extensions which is contributed for your editor will not work anymore.
If you mean the system menu that appears on editor tabs and view tabs, that menu is provided by the presentation (2.1, Classic, Default, etc). There is no tweak to simply modify it.
The 2 ways to remove it would be:
write your own presentation, using
the
org.eclipse.ui.presentations.StackPresentation
API and matching extension point.
Writing a presentation is a involved
undertaking.
Change the internal classes in the
org.eclipse.ui.workbench plugin
and patch that plugin in your RCP
app.
If you use Text or StyleText you will get the system default menu (cut,copy,paste, maybe something about encoding or input). If you are not going to supply your own menu, simply create an empty SWT Menu and set it:
Menu emptyMenu = new Menu(text);
text.setMenu(emptyMenu);
Eclipse also has a text editing framework, if you need more than a basic text box you should check it out. http://wiki.eclipse.org/The_Official_Eclipse_FAQs#Text_Editors