Change position of "answer dialog as sheet"

Richard Gaskin ambassador at fourthworld.com
Tue May 5 10:23:53 EDT 2015


Rolf Kocherhans wrote:

 > Is it possible to change the location of an „answer dialog as sheet“
 > on OS X ?
 >
 > I know that we can change the loc of a normal dialog box
 > (preOpenStack), but can we also do the same with a dialog box
 > opened as sheet respectively a stack opened as sheet ?
 >
 > I would like to move the dialog box/stack down approx. 20 pixels
 > because I would like to use it in a stack with a custom window shape.

There's a request in the RQCC to add SuperCard's "at <loc>" option to 
the ask and answer commands:
<http://quality.runrev.com/show_bug.cgi?id=4309>

Useful as that may seem, the behavior of the ask and answer dialogs is 
usually HIG-savvy enough that it's quite a rare edge case when we need 
them opened at a location other than what they do naturally.

However, a custom window is such an edge case. :)

Using a group may not be a bad option, esp. if the top edge of your 
window isn't a straight line since the dialog will appear in a way that 
fully takes your window's shape into account.  After all, you're already 
using a non-standard window, why not go all the way?

Alternatively, you can either modify the preOpenStack handler of the 
answer dialog, or insert a frontScript to handle that in conjunction 
with a custom property in which you specify the desired loc:


Caller script:

on mouseUp
    set the uCustomLoc of stack "answer dialog" to 400,400
    answer "Hello World"
end mouseUp


FrontScript:

on preOpenStack
    if the short name of this stack is "answer dialog" then
       get the uCustomLoc of stack "answer dialog"
       if it is a point then
          set the loc of stack "answer dialog" to it
       end if
     end if
     pass preOpenStack -- critical to pass messages in frontScripts
end preOpenStack

To avoid having to make sure you always either explicitly set the 
location property or clear it, you could also add this to the frontScript:

on closeStack
   if the short name of this stack is "answer dialog" then
      set the uCustomLoc of stack "answer dialog" to empty
   end if
   pass closeStack
end closeStack

-- 
  Richard Gaskin
  Fourth World Systems
  Software Design and Development for the Desktop, Mobile, and the Web
  ____________________________________________________________________
  Ambassador at FourthWorld.com                http://www.FourthWorld.com




More information about the use-livecode mailing list