Page 1 of 1

Buttons don't disappear

Posted: Sun Jan 18, 2015 1:26 am
by SheyMouse
In the code below is there a reason my my "...set visible of [button] to false!" code isn't functioning?

I have had a tinker and cannot get the button to disappear for when the printInvoiceis called,

Code: Select all

on printInvoice
   set the visible of button "btnPrint" to "false" 
   put specialFolderPath("documents") & "/Invoice013.pdf" into tPDFPath
   -- Handle the default text of the myCompany field
   if the text of field "myCompany" is "Your company" then
      set the visible of field "myCompany" to false
   else
      set the visible of field "myCompany" to true
   end if
       
   open printing to pdf tPDFPath
   if the result is "Cancel" then
      exit printInvoice
   else
      --print card "invoice" of this stack from 0,0 to 575,600 into 0,0,575,800
      print card "invoice" of this stack into 0,0,575,800
   end if
   
   close printing
   set the visible of button "btnPrint" to "true"
end printInvoice

Re: Buttons don't disappear

Posted: Sun Jan 18, 2015 2:19 am
by magice
Is it possible that button "btnPrint" is on a card other than the active card? If so adding "of cd CardNumber" could be the answer. I see nothing wrong with the code posted here , so it has to be something happening out of the scope of what you posted.

Re: Buttons don't disappear

Posted: Sun Jan 18, 2015 8:58 am
by Tukcedo
Not sure if this matters, but true and false are normally used without the quotes ...

Re: Buttons don't disappear

Posted: Mon Jan 19, 2015 2:35 pm
by SheyMouse
I moved all of the code from the stack script to the card script, the button was still visible when printing the pdf.

I then did a separate test by starting a new stack, adding a button and attaching the following script to the button:

Code: Select all

on mouseUp
    set the visible of button "Button" to false
end mouseUp
When I clicked the button in Run mode, the button didn't disappear. However, I did notice that the visible flag in the button properties is being unset. I wonder if there is some sort of bug with this.
Or maybe I'm just doing it wrong.

Re: Buttons don't disappear

Posted: Mon Jan 19, 2015 2:46 pm
by Klaus
I never had any problem setting the visibility of any object in LC in the last 15 years!
So I presume, there is something else going on, but have no idea what!?

Is this on Mac or Windows?

Re: Buttons don't disappear

Posted: Mon Jan 19, 2015 2:48 pm
by magice
SheyMouse wrote:I moved all of the code from the stack script to the card script, the button was still visible when printing the pdf.

I then did a separate test by starting a new stack, adding a button and attaching the following script to the button:

Code: Select all

on mouseUp
    set the visible of button "Button" to false
end mouseUp
When I clicked the button in Run mode, the button didn't disappear. However, I did notice that the visible flag in the button properties is being unset. I wonder if there is some sort of bug with this.
Or maybe I'm just doing it wrong.
Does it disappear when you print to the printer? I am curious if this may be a bug when printing to pdf. One other question though. Do you have "Show invisible objects" checked?

Re: Buttons don't disappear

Posted: Mon Jan 19, 2015 3:00 pm
by SheyMouse
@magice - I wouldn't know how to print to an actual printer.

If someone else more experienced reads this and wants to take a crack at it, that would be very useful.

Re: Buttons don't disappear

Posted: Mon Jan 19, 2015 3:03 pm
by Klaus
The scripts posted here look correct!?

Please also try this:
...
hide btn "btnPrint"
...
# Resp.
show btn "btnPrint"
...

Re: Buttons don't disappear

Posted: Mon Jan 19, 2015 3:11 pm
by SheyMouse
@Klaus - The results were the same as encountered earlier. The "Visible" box is being unchecked, but the button does not disappear.

Re: Buttons don't disappear

Posted: Mon Jan 19, 2015 3:15 pm
by Klaus
That's just too funky!? :D

Can you send me the (stripped down) stack, so I can take a look?
Will be much more effective that guessing around here for a couple of hours 8)
Send it to: klaus AT major-k.de

Is the stack in LC 7 format?
Does this happen on a Mac or WIndwos?

Re: Buttons don't disappear

Posted: Mon Jan 19, 2015 3:38 pm
by SheyMouse
@Klaus - email sent.

Re: Buttons don't disappear

Posted: Mon Jan 19, 2015 3:51 pm
by Klaus
Hmmmm, molto mysterioso, worked as exspected here on my Mac!
Out of ideas currently... :?

Re: Buttons don't disappear

Posted: Mon Jan 19, 2015 4:03 pm
by SparkOut
Have you got "Show invisible objects" checked in the View menu maybe?

Re: Buttons don't disappear

Posted: Mon Jan 19, 2015 5:01 pm
by SheyMouse
All,

Thank you for your help and replies. Based on a chat with Klaus, and the other replies, I decided to take a look at my installation.

It appears as though an old installation, possibly 6.x or 7.0 (RC2) was having an influence on my install. Removing all older versions of LiveCode resulted in the button disappearing as expected.

Thanks for your support.