[ANSWER TO OWN QUESTION]Re: Custom Modal List Dialog Methodology

Stephen Barncard stephenREVOLUTION at barncard.com
Sat Jun 25 15:40:12 EDT 2005


I think I got it while the listserv was down...this works nicely.
Wait For Messages inside a repeat loop conditional on a flag.
The alternate single line method,

wait until gDialogFlag is "false"  with messages


  as I've found and Dave Cragg suggested, seems to tie up resources a 
la  the dreaded 'idle'.

in the stack script:

function dialogList pPrompt,pListData
   global gDialogFlag
   local DD,tDialogTxt
   if there is a stack "listDialog"
   then
     put scrunch(pPrompt) & return & scrunch(pListData) into tDialogTxt
     set the dialogData to tDialogTxt
     open stack "listDialog"
     put "true" into gDialogFlag

     --  wait for modal dialog to quit
     repeat until gDialogFlag is "false"
       wait for messages
     end repeat

     --  resume execution here
     put the dialogData into  DD
   end if
   return DD
end dialogList

function scrunch x
   replace return with numToChar(11) in x
   return x
end scrunch

function unscrunch x
   replace numToChar(11) with return in x
   return x
end unscrunch

-- this is in the stack script of the dialog

global gDialogFlag

on acceptTheEntry
   -- we are accepting this selection
   set the dialogdata to the selectedText of fld "listField"
   close this stack
end acceptTheEntry

on acceptNOTTheEntry
     -- we are NOT accepting this
     set the dialogdata to empty
     close this stack
end acceptNOTTheEntry

on openstack
   get the dialogData
   put unscrunch(line one of it) into fld "promptField"
   put unscrunch(line two of it) into fld "listField"
   pass openStack
end openstack

on closeStack
   --  we need to continue execution now
   put "false" into gDialogFlag
   pass closeStack
end closeStack

on escapeKey
   acceptNOTTheEntry
end escapeKey

on returnKey
   acceptTheEntry
   pass returnKey to top
end returnKey




More information about the use-livecode mailing list