Getting/setting the selection in cocoa apps
Getting/setting the selection in cocoa apps
- Subject: Getting/setting the selection in cocoa apps
- From: John Delacour <email@hidden>
- Date: Tue, 1 Apr 2003 01:35:56 +0100
- Mac-eudora-version: 6.0a14
At 12:20 pm -0800 28/3/03, cricket wrote:
You are correct that there is no way to get the selection in Cocoa
applications, other than using UI scripting...
I can now assert that this is an utter falsehood.
Script Editor 2 is a cocoa application.
It is possible to set and get the selection (selected text) in any
document of Script Editor 2.
It is therefore possible to get and set the selection in ANY cocoa
application, though it is not possible to use the syntax "selection
as string", which is an omission.
If this routine is not feasible in TextEdit or in Mail.app, it is
because the people responsible for these applications have not made
it feasible.
tell app "Script Editor"
set d to make document at its end
tell d
set its text to "Hello World"
set selection to characters 1 through 4 of its text
contents of the selection
display dialog result
end
end
--JD
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.