• 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
Re: Tell Blocks Considered Harmful (was Re: open for access)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Tell Blocks Considered Harmful (was Re: open for access)


  • Subject: Re: Tell Blocks Considered Harmful (was Re: open for access)
  • From: Philip Aker <email@hidden>
  • Date: Tue, 16 Dec 2008 06:10:42 -0800

On 2008-12-15, at 17:47:42, Chris Page wrote:

As an AppleScript user, my opinion about the general case is that I agree with the other folks who think it's _not_ a good plan to whack modal capability. Modal dialogs are a fundamental UI requirement (i.e. password before proceeding). Just a wild guess, but if you're in a pinch for a modal box which might serve in a chain of asynchronous facilities in a larger context which doesn't want to be disturbed, I'm wondering if CFUserNotificationDisplayAlert() and CFUserNotificationDisplayNotice() would be viable alternatives.

To be clear, when a script issues the ‘display dialog’ command, the script pauses until the dialog is dismissed and the command is completed. Similarly, the application running the script usually pauses, too. Most applications don't respond to user input while waiting on an Apple Event to reply.

The I believe the behavior is determined by the send mode options such as kAEQueueReply and kAEProcessNonReplyEvents.


The defining feature of a modal dialog is that it prevents user interaction with the rest of the application that is displaying the dialog. What we're discussing is whether it's important to prevent user interaction with another application, in addition to the one running the script.

If you open Script Editor and run:

  tell application "Finder" to display alert "Hi!"

Script Editor will be unresponsive to user input while the script waits for the Apple Event reply from Finder. In addition, since Finder is displaying a modal dialog, the user cannot interact with Finder windows or the Desktop. Similarly, if you put that script into a script applet, the applet will not respond to user input while the script is waiting on the reply from Finder.

Is it important to prevent user interaction with applications in addition to the one running the script?

Well yes and no. In the 'no' case it would be in order to allow the fewest possible side-effects to the intent of the script (say in a situation where dialogs are called sequentially to elicit more than a single string from the user to determine the eventual flow of the script).

But here's what I think you mean by a 'yes' case. Let's call our apps Sender, Target, and Interloper.

Sender is filling out a form in Target which has 20 fields in it but it only requires 2 strings from the user to auto-complete the fields. Sender sends this script to Target.

try
tell application "Target"
-- dd#1
set field "UnixUserName" of form 1 to text returned of (display dialog "AppleScript Team member name:" default answer "chris")
end tell
my AutoCompleteUserFields() -- targets another app and gets some input values on idle 
tell application "Target"
-- dd#2
set psize to text returned of (display dialog "Page size:" default answer "8.5x11")
end tell
my AutoCompletePageFormat(psize)
my ProcessPrintJobFolderFromCurrentForm()
end try

Now the script is running and paused at dd#1 but Interloper has a script aimed at Target which it sends on startup. Guess what? It's being run from a cron job and activates while the user is typing into dd#1 with the intent to fill out field "UnixUserName". Because the 'yes' behavior permits interaction, then before AutoCompleteUserFields() is called, field "UnixUserName" will be filled out with potentially incorrect information. And even if that event couldn't get there before AutoCompleteUserFields(), it sure will on Sender's idle handler. Now it's easy to see that I could reformat the script above to try to insure my values are correct, but I think the point is that Sender's idle handler permits Interloper to access Target and thus a potential interceptions of the script's intent. That's what folks want to avoid because there are other possible scenarios where you'd be using values from say Target's application properties and want them to be reliably set for the duration of the script.

Judging by the comments of other posters to this question, the sentiment is certainly against other application interaction -- or even the perception of it.


Philip Aker
echo email@hidden@nl | tr a-z@. p-za-o.@

Democracy: Two wolves and a sheep voting on lunch.

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Tell Blocks Considered Harmful (was Re: open for access)
      • From: Chris Page <email@hidden>
References: 
 >Re: Tell Blocks Considered Harmful (was Re: open for access) (From: Shane Stanley <email@hidden>)
 >Re: Tell Blocks Considered Harmful (was Re: open for access) (From: Chris Page <email@hidden>)
 >Re: Tell Blocks Considered Harmful (was Re: open for access) (From: Philip Aker <email@hidden>)
 >Re: Tell Blocks Considered Harmful (was Re: open for access) (From: Chris Page <email@hidden>)
 >Re: Tell Blocks Considered Harmful (was Re: open for access) (From: Philip Aker <email@hidden>)
 >Re: Tell Blocks Considered Harmful (was Re: open for access) (From: Chris Page <email@hidden>)
 >Re: Tell Blocks Considered Harmful (was Re: open for access) (From: Philip Aker <email@hidden>)
 >Re: Tell Blocks Considered Harmful (was Re: open for access) (From: Chris Page <email@hidden>)
 >Re: Tell Blocks Considered Harmful (was Re: open for access) (From: Philip Aker <email@hidden>)
 >Re: Tell Blocks Considered Harmful (was Re: open for access) (From: Chris Page <email@hidden>)

  • Prev by Date: Re: Tell Blocks Considered Harmful (was Re: open for access)
  • Next by Date: Re: Tell Blocks Considered Harmful (was Re: open for access)
  • Previous by thread: Re: Tell Blocks Considered Harmful (was Re: open for access)
  • Next by thread: Re: Tell Blocks Considered Harmful (was Re: open for access)
  • Index(es):
    • Date
    • Thread