Page 1 of 1

Importing an image via a button into a different stack?

Posted: Wed Jan 17, 2024 12:44 pm
by richmond62
Imagine, if you will, a palettised stack containing a button with this script:

Code: Select all

on mouseUp
   answer file "Select image:"
   if the result is not cancel then
      set the lockscreen to true
      put the short name of the topStack into STAKK
      import paint from file it to stack STAKK
      set the name of the last control to "XYZ"
   end if
end mouseUp
Now what ACTUALLY happens with this script is that my imported image ends up in the stack containing my button, and NOT my target stack.

Re: Importing an image via a button into a different stack?

Posted: Wed Jan 17, 2024 4:00 pm
by bn
Richmond,

this works for me.

Code: Select all

on mouseUp
   put the topStack into STAKK
   if (the short name of this stack) is STAKK or STAKK is empty then
      answer "activate the target stack first" with "Ok"
      exit mouseUp
   end if
   answer file "Select image:"
   if the result is not cancel then
      set the lockscreen to true
      set the defaultStack to STAKK
      import paint from file it 
      set the name of the last control to "XYZ"
   end if
end mouseUp
Kind regards
Bernd

Re: Importing an image via a button into a different stack?

Posted: Wed Jan 17, 2024 4:14 pm
by richmond62
Super!

Thank you, Bernd.