ask dialog not appearing in my stack

Wilhelm Sanke sanke at hrz.uni-kassel.de
Wed Jul 17 12:51:00 EDT 2002


Looking through the digests it seems to me that the last request of
Chipp Walters of July, 7th, has not yet been asnwered.

Chipp Walters" <chipp at chipp.com> on Sun, 7 Jul 2002 wrote:


> Found the windows...but no code. Do you know where the answer code might be located? Or is it 'hard-wired?'
> It seems to me that: answer "hello world" with "okay" or "cancel" doesn't conform to handler syntax...or does it? (with
> not defined) btw- can't find the code in debug mode either.
> best,
> Chipp
>
Hi Chipp,

the Rev answer dialog has 1 card, with 1 field, 1 icon button, and 7
more buttons with the IDs from 1240 to 1242 and 1245 to 1248. All
controls are *without" code, i.e. scripts.

The only code is in the card script, which is rather long. If you do not
need the full flexibility of the Rev answer dialog, you should write
your own customized - and very short - answer dialog, which is even
possible within the restrictions of the Starter Kit.

Regards,

Wilhelm Sanke

Here is the full text of the answer dialog script:

##Card Script of  Rev answer dialog
on preOpenStack
  global gAPKLargeFonts
  --platform specific font adjustments
  set the defaultStack to "answer dialog"
  set the default of button 2 to false
  switch the platform
  case "MacOS"
    set the loc of this stack to the screenLoc
    set the top of this stack to round(item 4 of the screenRect/5)
    repeat with i = 2 to the number of btns
      set the bottomMargin of btn i to 3
      set the height of btn i to 20
    end repeat
    if char 1 of the systemVersion is 1 then
      --OS X
      set the textFont of this stack to "Lucida Grande"
      set the textSize of this stack to 13
      set the textSize of fld 1 to 11
      put "210002 210001 210012 210009" into tIcons
    else
      set the textFont of this stack to "usesystemfont"
      set the textSize of this stack to 12
      set the textFont of fld 1 to "Geneva"
      set the textSize of fld 1 to 10
      put "210002 210001 210012 210009" into tIcons
    end if
    break
  case "Win32"
    if gAPKLargeFonts then
      put 26 into tNumber
      put 7 into tMargin
    else
      put 21 into tNumber
      put 5 into tMargin
    end if
    repeat with i = 2 to the number of btns
      set the bottomMargin of btn i to tMargin
      set the height of btn i to tNumber
      set the traversalOn of btn i to false
      set the mnemonic of btn i to 0
    end repeat
    set the textFont of this stack to "MS Sans Serif"
    set the textSize of this stack to 10
    set the textFont of fld 1 to empty
    put "210005 210011 210003 210004" into tIcons
    break
  default
    repeat with i = 2 to the number of btns
      set the bottomMargin of btn i to 4
      set the height of btn i to 21
      set the traversalOn of btn i to false
      set the mnemonic of btn i to 0
    end repeat
    set the textFont of this stack to "Helvetica"
    if gAPKLargeFonts then set the textSize of this stack to 14
    else set the textSize of this stack to 12
    set the textFont of fld 1 to empty
    put "210008 210010 210006 210010" into tIcons
    break
  end switch
  --is there an icon to display or not?
  set the itemDelimiter to numToChar(0)
  if word 2 of item 1 of the dialogData is "plain" then
    set the loc of btn 1 to -100,21
    put 0 into tIconAllowance
  else
    set the loc of btn 1 to 26,21
    set the icon of button "icon" to word wordOffset(word 2 of item 1 of
the dialogData, "information error warning question") of tIcons
    put 40 into tIconAllowance
  end if
  --title
  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
  put item 3 of dialogData into fld 1
  if the platform is "MacOS" then
    set the textFont of fld 1 to "usesystemfont"
    set the textSize of fld 1 to 12
  end if
  --buttons
  put item 4 of dialogData into tButtonNames
  put the number of lines in tButtonNames into tNoOfButtons
  if tButtonNames is empty then
    put "OK" into tButtonNames
    put 1 into tNoOfButtons
  end if
  put 32 into tTotalBtnWidth
  --truncate more buttons to the maximum allowed (7)
  if tNoOfButtons > the number of buttons - 1 then put the number of
buttons - 1 into tNoOfButtons
  put empty into tMnemonicString
  repeat with i = 2 to (tNoOfButtons + 1)
    --   put "got here 1" && i && tNoOfButtons
    --set the loc of btn i to the cPrevLoc of btn i --show btn
    set the name of button i to line tNoOfButtons - (i - 2) of
tButtonNames
    -- put "got here 2" && i
    if the platform is "Win32" and the short name of btn i is not in
"OKCancel" then
      --  put "got here 3" && i
      put 0 into tNo
      --put "got here 4" && i
      repeat for each char x in the short name of btn i
        --  put "got here 5" && i
        add 1 to tNo
        --     put "got here 6" && i
        if x is not in tMnemonicString then
          --     put "got here 7" && i
          put x after tMnemonicString
          --   put "got here 8" && i
          set the mnemonic of btn i to tNo
          --   put "got here 9" && i
          exit repeat
          --   put "got here 10" && i
        end if
        --   put "got here 11" && i
      end repeat
      --  put "got here 12" && i
    end if
    set the width of button i to 58
    --    put "got here 13" && i
    if the width of btn i < the formattedWidth of btn i then set the
width of btn i to the formattedWidth of btn i + 8
    --  put "got here 14" && i
    add the width of button i + 12 to tTotalBtnWidth
    --  put "got here 15" && i
  end repeat
  set the dontWrap of field 1 to true
  put max(the formattedWidth of field 1 + tIconAllowance + 16,
tTotalBtnWidth) into tWidth
  if tWidth < 278 then put 278 into tWidth
  if tWidth > 600 then
    put 600 into twidth
    set the width of field 1 to twidth - tIconAllowance - 16
    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
  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 top of button 1 to the height of field 1 div 2 - 12
  set the top of btn 1 to 6
  set the topLeft of field 1 to tIconAllowance + 8, 8
  set the itemDel to comma
  get the rect of fld 1
  put (the width of this stack - 12) into item 3 of it
  set the rect of fld 1 to it
  put the width of this stack -12 into tStartRight

  if the platform is "MacOS" then
    repeat with i = 2 to tNoOfButtons + 1
      set the right of btn i to tStartRight
      subtract the width of btn i + 12 from tStartRight
      set the bottom of btn i to the height of this stack - 12
    end repeat
  else
    repeat with i = (tNoOfButtons + 1) down to 2
      set the right of btn i to tStartRight
      subtract the width of btn i + 12 from tStartRight
      set the bottom of btn i to the height of this stack - 12
      set the traversalOn of btn i to true
    end repeat
  end if
  if the platform is "MacOS" then set the top of this stack to
round(item 4 of the screenRect/5)
  set the default of button 2 to true
end preOpenStack

on commandKeyDown pKey
  if pKey is "." then
    if there is a btn "Cancel" then
      click at the loc of btn "cancel"
      exit commandKeyDown
    end if
  end if
  repeat with i = 2 to the number of btns
    if item 1 of the loc of btn i < 1 then next repeat
    if char 1 of the short name of btn i is pKey then
      click at the loc of btn i
      exit repeat
    end if
  end repeat
end commandKeyDown

on escapeKey
  if there is a btn "cancel" then click at the loc of btn "cancel"
end escapeKey

on closeStack
  --show invisibles compatible removal of btns
  repeat with i = 3 to the number of buttons
    set the cPrevLoc of btn i to the loc of btn i
    set the loc of btn i to -100,-100
  end repeat
  set the dialogData to empty
end closeStack

on mouseUp
  if the name of the target contains "button" then
    close this stack
    set the dialogData to the short name of the target
  end if
end mouseUp

on returnKey
  pass returnKey to top
end returnKey




More information about the Use-livecode mailing list