[WTF] MC's Answer Dialog Options Flipped?

J. Landman Gay jacque at hyperactivesw.com
Wed Aug 31 21:54:28 CDT 2005


Ken Ray wrote:

> It's an IDE change - b11 has a comment in the Version History that "Ask and
> Answer dialogs now have their button positions placed according to the Mac
> OS HIG when running on that platform." It changed between b6 and b11 (I
> think it was b11).
> 
> Richard could tell you better...

I took a a look at it. Below is a corrected preOpenStack handler. Anyone 
who wants it can paste it into the first card of the "answer dialog" 
stack (watch for line wrap.) There were three places that needed 
correction. I've initialed them, in case it is easier to just find those 
lines and change them.

Somebody should test it on platforms other than Mac.

Revised handler:

on preOpenStack
   local dtype, foffset, oldwidth, bwidth, twidth, iwidth, theight, 
curx, nchoices
   set the itemDelimiter to numToChar(0)
   put word 2 of item 1 of the dialogData into dtype
   if dtype is "plain" then
     hide button 1
     put 0 into foffset
   else
     global gMCappicon
     if gMCappicon <> empty then
       set the icon of button "icon" to gMCappicon
     else
       switch the lookAndFeel
       case "Motif"
         get the motifIcons of this stack
         break
       case "Macintosh"
       case "Appearance Manager"
         get the macintoshIcons of this stack
         break
       default
         get the windows95Icons of this stack
       end switch
       set the itemDelimiter to comma
       set the icon of button "icon" to item itemOffset(dtype, 
"error,information,question,warning") of it
     end if
     set the itemDelimiter to numToChar(0)
     put 104 into foffset
     show button 1
   end if

   if item 2 of the dialogData is empty then
     set the title of this stack to space
   else
     set the title of this stack to item 2 of the dialogData
   end if

   put item 3 of dialogData into field 1
   get item 4 of dialogData

   if it is empty then get "OK"
   put the number of lines in it into nchoices
   put 32 into bwidth
   if nchoices > the number of buttons - 1 then
     put the number of buttons - 1 into nchoices
   end if

   # repeat with i = 2 to nchoices + 1
   # set the default of btn i to false
   # show button i
   # set the name of button i to line nchoices + 2 - i of it
   # set the width of button i to the formattedWidth of button i + 24
   # add the width of button i + 32 to bwidth
   # end repeat

   # repeat with i = nchoices + 1 down to 2
   repeat with i = 2 to nchoices + 1 -- JG
     put line nchoices + 2 - i of it into bname
     set the default of btn i to false
     show button i
     set the name of button i to bname
     if bname = "OK" OR bname = "Cancel" or the num of chars of bname <= 
7 then
       set the width of btn i to 68
       ## Apple HIG for OS X
     else
       set the width of button i to the formattedWidth of button i + 32
     end if
     add the width of button i + 32 to bwidth
   end repeat

   set the dontWrap of field 1 to true
   put max(the formattedWidth of field 1 + foffset + 24, bwidth) into twidth
   if twidth > 460 then
     put 460 into twidth
     set the dontWrap of field 1 to false
   end if
   put the width of this stack into oldwidth
   set the width of this stack to twidth
   set the width of field 1 to twidth - foffset - 16
   put the formattedHeight of field 1 + 68 into theight
   if theight > 400 then
     set the vScrollbar of field 1 to true
     put 400 into theight
   else set the vScrollbar of field 1 to false
   set the height of this stack to theight
   set the height of field 1 to theight - 68

   set the topLeft of field 1 to foffset,15
   ## Apple HIG presumes icons to be 64*64 pixel

   put (twidth - bwidth) div (nchoices + 1) + 32 into iwidth
   put iwidth into curx
   if the lookAndFeel is "Macintosh" or the lookAndFeel is "Appearance 
Manager" then
     put twidth - 24 into anfangrechts
     ## repeat with i = nchoices + 1 down to 2
     repeat with i = 2 to nchoices + 1 -- JG
       set the right of button i to anfangrechts
       subtract the width of button i from anfangrechts
       subtract 12 from anfangrechts
       set the bottom of button i to the height of this stack - 20
     end repeat
   else
     repeat with i = 2 to nchoices + 1
       set the left of button i to round(curx)
       add the width of button i + iwidth to curx
       set the bottom of button i to the height of this stack - 16
     end repeat
   end if
   set the default of btn 2 to true -- JG

   set the dialogData to empty
end preOpenStack




-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com


More information about the metacard mailing list