Subwindow error

Martin Baxter martin at materiaprima.fsnet.co.uk
Tue Jun 7 13:05:48 EDT 2005


>Hello,
>
>I have coded the following script to the button "micron".
>
>on arrowKey theKey
>  if theKey is "down" then popup btn micron  at 230,225
>end arrowKey
>
>on menuPick theItem
>  set the label of the btn "micron" to theItem
>  set the menuMode of btn "micron" to comboBox
>end menuPick
>
>The popup menu would be displayed when down arrowKey is pressed. But, the
>following error is generated when ever the down arrorKey is keyed in for
>the first time after opening the main stack.
>
>Error:
>------
> Type   :  subwindow: can't find stack or button
> Object :  micron
> Line   :  popup btn micron at 230,225
> Hint   :  true
>
>Could anyone please tell me where I am going wrong.
>
>--
>Thanking you,
>
>Dayakar N
>

Hello Dayakar,

I confess that I don't really understand the error either, but I did manage
to get your script to work in the way I think you want. The error message
occurs here after the popup menu has been displayed and you then press the
arrow key again to change the menu selection. (if I make a menu selection
with a mouse click there is no error).
The script below worked OK here - note the local variable l_popon which is
initialised to false. This allows the script to ignore the second arrow key
press. The trouble is that when you use the arrow key again it tries to
popup the menu again instead of just making a selection. - clear ? I hope
so :-)

local l_popon = false

on arrowKey theKey
  if theKey is "down" and l_popon is false then
    put true into l_popon
    popup btn "micron"  at "230,225"
  else
    pass arrowkey
    -- so the engine can operate the menu for you
  end if
end arrowKey

on menuPick theItem
  set the label of the btn "micron" to theItem
  set the menuMode of btn "micron" to comboBox
  put false into l_popon
  -- now l_popon is false again like at the start and next
  -- arrowkey will popup the menu again
end menuPick

Hope this helped,

Martin Baxter





More information about the use-livecode mailing list