Getting a field name

Jim Hurley jhurley at infostations.com
Mon Apr 5 10:22:29 EDT 2004


Ken Ray wrote:


>Jim,
>
>How about this (answers the clicked field, but "cancels" if the next object
>clicked is not a field):
>
>-- script of palette button:
>
>on mouseUp
>   global gClickedField
>   put "" into gClickedField
>   answer "Click on the application field."
>   insert script of btn "clickTrapper" into front
>   wait until gClickedField is not empty
>   if gClickedField <> "***CANCEL***" then
>     answer "The field clicked on was:" && gClickedField
>   else
>     -- something else was clicked on
>     -- do what you want in this case
>   end if
>end mouseUp
>
>-- script of btn "clickTrapper"
>
>on mouseUp
>   global gClickedField
>   if word 1 of the target is "field" then
>     put the short name of the target into gClickedField
>   else
>     put "***CANCEL***" into gClickedField
>   end if
>   remove script of me from front
>end mouseUp
>
>
>HTH,
>
>Ken Ray


Ken,

Thanks for the suggestion. I tried it but got stuck in an endless 
wait. I don't see why that should have happened.

I put a "beep" into the first line of the second "mouseUp" handler, 
but I never heard a peep (beep) from it.

So why doesn't that front script receive the message? This is new 
territory for me.

Jim



--------------------------------------
Richard Gaskin wrote:

>
>I haven't seen the code so I'm just guessing here, but would it help to
>add something like:
>
>     set the defaultStack to the topStack
>
>--
>   Richard Gaskin
>   Fourth World Media Corporation
>   ___________________________________________________________
>   Ambassador at FourthWorld.com       http://www.FourthWorld.com

Richard,

Good thought! I had hopes for this suggestion. But once again 
mouseControl came up empty. That is the handler:

on mouseup
   set the defaultStack to the topstack
   answer "Click on the field to use." with OK
    set the defaultStack to the topstack
   wait until the mouseclick
   set the defaultStack to the topstack
   put the mouseControl into tFieldName
end  mouseUP


reveals an empty "theFieldName" . (As you see, I left no stone 
unturned in setting the default stack. I tried various and sundry 
combinations of the above..)

I do have a work-around that works--As W. C. Fields said, when he 
bumped into Mae West: "Pardon my redundancy."

on mouseup
   answer "Click on the field to use." with "OK" or "Cancel"
   if it is "Cancel" then exit mouseUP
   wait until the mouseclick
   put the clickloc into tLoc
   put the clickstack into tStackName
   put the number of fields in tStackName into tNum
   repeat with i = 1 to tNum
     if tloc is within the rect of field i of tStackName then
       put the  name of field i of  tStackName into tClickField
       exit repeat
     end if
   end repeat
--and the rest is bookkeeping.

end mouseup


More information about the use-livecode mailing list