• 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
Work-around to TextEdit "close front window saving no"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Work-around to TextEdit "close front window saving no"


  • Subject: Work-around to TextEdit "close front window saving no"
  • From: Emile Schwarz <email@hidden>
  • Date: Sun, 17 Jul 2005 11:20:17 +0200

Hi all,


after some intensive testings, I found a work-around for the infamous TextEdit bug:

tell application "TextEdit"
	-- place the application frontmost
	activate

	-- discard the changes for the front window
	close front window saving no
end tell


The work-around follows. It work fine 'as is': it fits my needs. But I do not know about a possible inter-action with other elements. I only have a TextEdit document with unsaved changes and the ScriptEditor running the script. Other than that I do not know:


tell application "TextEdit"
	-- place the application frontmost
	activate

	-- discard the changes for the front window
	close front window saving no

	-- this is the bug work-around part
	tell application "System Events"
		-- simulate a Command-D press from the user !
		keystroke "d" using {command down}
	end tell

	-- set my application frontmost
	tell current application
		activate
	end tell
end tell


I hope this helps,

Emile


PS: the saving sheet dialog contains three buttons (translated from French, can be a bit different than my translation), from left to right:


a. Don't save     --> Command-D
b. Cancel         --> Esc [or Command-.]
c. Save           --> Command-S


About System Events’ keystroke:
-------------------------------
keystroke v : cause the target process to behave as if keystrokes were entered
keystroke Unicode text : The keystrokes to be sent.
[using command down/control down/option down/shift down] : modifiers with which the keystrokes are to be entered


About TextEdit close:
---------------------
close v : Close an object.
close reference : the object for the command
[saving ask/no/yes] : Specifies whether changes should be saved before closing.
[saving in alias] : The file in which to save the object.


_______________________________________________ Do not post admin requests to the list. They will be ignored. Applescript-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Prev by Date: copy {""} to end of list
  • Next by Date: Using the document element in TextEdit
  • Previous by thread: Re: copy {""} to end of list
  • Next by thread: Using the document element in TextEdit
  • Index(es):
    • Date
    • Thread