• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Getting/setting the selection in cocoa apps
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: Getting/setting the selection in cocoa apps
      • From: cricket <email@hidden>
  • Prev by Date: Re: Looking for AppleScript to Log Websites Visited
  • Next by Date: Find Window And the Find Dialog
  • Previous by thread: Re: Looking for AppleScript to Log Websites Visited
  • Next by thread: Re: Getting/setting the selection in cocoa apps
  • Index(es):
    • Date
    • Thread