Show/Hide not working

Moderators: LCNeil, heatherlaine, kevinmiller, elanorb

Post Reply
roddy
Posts: 40
Joined: Tue Mar 04, 2014 7:24 pm

Show/Hide not working

Post by roddy » Wed Apr 09, 2014 9:43 pm

Hello - I'm showing/hiding progress bar and start button with on preopencard in the card script but it only works the first time I open the stack. If I navigate back to the splash card it doesn't reset... my stack is 1.1mb and forum won't let me upload. How can I get it to you?

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 774
Joined: Fri Aug 15, 2008 7:15 am

Re: Show/Hide not working

Post by bangkok » Wed Apr 09, 2014 10:45 pm

Copy here your script so we can have a look.

I think there is some confusion : if you want object appearance to change when you leave the card ("If I navigate back to the splash card it doesn't reset") then you have to use

Code: Select all

on closecard

end closecard

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am
Location: Bordeaux, France

Re: Show/Hide not working

Post by Dixie » Wed Apr 09, 2014 10:48 pm

explain a little more... should the progress bar & button show when your stack first opens ?.. Should it then be hidden when you return to the first card ?..

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3900
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Show/Hide not working

Post by Simon » Wed Apr 09, 2014 11:32 pm

Hi roddy,
If you are refering to this:
http://forums.runrev.com/phpBB2/viewtop ... 53#p101003

Then you have to reset x back to 0

Code: Select all

if x >= 400 then 
put 0 into x
I take it you've added the "show scrollbar..."?

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

roddy
Posts: 40
Joined: Tue Mar 04, 2014 7:24 pm

Re: Show/Hide not working

Post by roddy » Thu Apr 10, 2014 3:53 pm

Thanks for the responses.

Here is my card script on my splash card (card 1):

on preopencard
hide button "start"
show group "splashScrollbar"
show fld "load"
   set the mgValue of control "splashScrollbar" to 0
   goScroll
end preopencard

local x
on goScroll
   add 1 to x
   if x >= 400 then
      lock screen for visual effect
      hide group "splashScrollbar"
      hide field "load"
      show button "start"
      unlock screen with visual effect dissolve
      exit goScroll
   end if
   set the mgValue of group "splashScrollbar" to x/4
   send goScroll to me in 10 millisec
end goScroll

on closecard
set the mgValue of group "splashScrollbar" to 0
end close card
--
This works the first time I open the stack in LC and in the simulator. But, if I navigate back to card 1 in LC it doesn't. Also, I have to quit LC and restart to get it to work, if I just close and open the stack, it opens to the splash screen with the start button showing and the progress scroll bar is hidden.

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 774
Joined: Fri Aug 15, 2008 7:15 am

Re: Show/Hide not working

Post by bangkok » Thu Apr 10, 2014 4:06 pm

Add
put 1 into x

Code: Select all

local x
on preopencard
   put 1 into x
   hide button "start"
   show group "splashScrollbar"
   show fld "load"
   set the mgValue of control "splashScrollbar" to 0
   goScroll
end preopencard

Code: Select all

on closecard
   set the mgValue of group "splashScrollbar" to 0
end close card
Watch out : "closecard" without space

Code: Select all

on closecard
   set the mgValue of group "splashScrollbar" to 0
end closecard

roddy
Posts: 40
Joined: Tue Mar 04, 2014 7:24 pm

Re: Show/Hide not working

Post by roddy » Thu Apr 10, 2014 4:55 pm

Thanks, that works, but I have no idea why. How does "put 1 into x" cause my show/hide commands to start working? Also, now the scrollbar take about 20 seconds in LC to complete but works correctly (4 seconds) in the simulator...
bangkok wrote:Add
put 1 into x

Code: Select all

local x
on preopencard
   put 1 into x
   hide button "start"
   show group "splashScrollbar"
   show fld "load"
   set the mgValue of control "splashScrollbar" to 0
   goScroll
end preopencard

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 774
Joined: Fri Aug 15, 2008 7:15 am

Re: Show/Hide not working

Post by bangkok » Thu Apr 10, 2014 7:37 pm

roddy wrote:Thanks, that works, but I have no idea why. How does "put 1 into x" cause my show/hide commands to start working? Also, now the scrollbar take about 20 seconds in LC to complete but works correctly (4 seconds) in the simulator...
That's the logic. You add 1 to "something"... but you didn't give a value to this "something" to start... hence the problem.
:)

But I still think that you overshoot the script, just to show / hide with a group a visual effect.

One line should be enough. For instance :

Code: Select all

hide button "start"
show fld "load"
show grp "splashScrollbar" with visual effect iris open slowly

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3900
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Show/Hide not working

Post by Simon » Thu Apr 10, 2014 9:20 pm

Hi roddy,
Do you know how to use breakpoints?
After you run that script the first time x >= 400 and it remains that way. Go to the beach and come back, as long as you didn't shut the app down x >= 400. Have lunch, take the dog out for a walk x>=400.
So you have to reset it, put 0 into x.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Post Reply

Return to “idea2app and Coding School”