Set Controls as Non-Printable?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
cmhjon
Posts: 191
Joined: Tue Aug 04, 2015 11:55 am

Set Controls as Non-Printable?

Post by cmhjon » Thu Mar 22, 2018 1:05 pm

Hi all,

Although I know I can write a script to hide buttons before printing, is there some way of assigning a non-printing property to a button (or other control)? I am working on an app that will include the printing of cards but don't want the buttons on said cards to appear on printed output.

Thank you,
Jon :)

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10324
Joined: Wed May 06, 2009 2:28 pm

Re: Set Controls as Non-Printable?

Post by dunbarx » Thu Mar 22, 2018 2:28 pm

Hi.

This is not possible; there is no such property.

But is it so onerous to set a custom property for all the controls that you do not want to print? Sort of the same thing you had in mind, no? You then loop through all controls and hide those with the "doNotPrint" property set.

Code: Select all

repeat with y = 1 to the number of controls
 if the doNotPrint of control y = "true" then hide control y
 print.... 
Craig Newman

cmhjon
Posts: 191
Joined: Tue Aug 04, 2015 11:55 am

Re: Set Controls as Non-Printable?

Post by cmhjon » Fri Mar 23, 2018 1:07 pm

Hi Craig,

Thank you for the reply. Fortunately, there are only 4 controls that need hidden prior to printing which I have scripted. I wonder if perhaps a non-printing property is something worth consideration by LC to add in a future version of LC.

I haven't played with custom properties yet but will look into it.

Thank you so much,
Jon :)

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10324
Joined: Wed May 06, 2009 2:28 pm

Re: Set Controls as Non-Printable?

Post by dunbarx » Fri Mar 23, 2018 5:17 pm

Hi.

The number of controls is not important. The repeat loop will take no time at all, and you can manage the custom property easily. Experiment a little. Make a handful of buttons, set a custom property for half of them. something like "changeColor". Then in a repeat loop in the card script:

Code: Select all

on mouseUp
  repeat with y = 1 to the number of btns
    if the changeColor of fid y then set the backColor of fld y to any item of "red,green,blue,orange"
   end repeat
 end mouseUp
Click on the card.

As for whether this ought to be a new feature in LC, you can certainly make your case. But because a handler that does this very thing is so simple, fast and compact, I doubt whether it will get traction. But feel free to start a thread on the "Features Request" page, or go directly to the QCC.

Craig

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Set Controls as Non-Printable?

Post by FourthWorld » Fri Mar 23, 2018 5:24 pm

If practical to group the controls that you'd like hidden for printing then the brief code needed to hide them gets even shorter, just a single line to hide the group.

I like the idea of a built-in property to govern appearance in printed output, but given the wide range of ways people handle printing, and the ease of hiding and showing objects on the fly, you may find over time that it might be less useful than originally anticipated.

For example, if the trigger is when rendering to a print buffer, how would one implement a Print Preview which renders to the screen? We can handle these things flexibly with what he have now.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

cmhjon
Posts: 191
Joined: Tue Aug 04, 2015 11:55 am

Re: Set Controls as Non-Printable?

Post by cmhjon » Fri Mar 23, 2018 5:41 pm

Craig,

I have never played with custom properties, let alone know how to implement them. Please understand that I am an LC newbie who came from a HyperCard background (kind of dates it doesn't it? LOL).

From everything I have seen and read, I am blown away by LC's capabilities (compared to HyperCard).

Best regards,
Jon :)

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Set Controls as Non-Printable?

Post by FourthWorld » Fri Mar 23, 2018 5:47 pm

The discussion of custom properties in the User Guide (beginning on p 154) provides good orientation and some useful examples.

You can access the User Guide through LC's Help menu.

You'll love custom properties. They open up so many flexible ways to bind data to objects.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10324
Joined: Wed May 06, 2009 2:28 pm

Re: Set Controls as Non-Printable?

Post by dunbarx » Fri Mar 23, 2018 9:38 pm

I have never played with custom properties, let alone know how to implement them. Please understand that I am an LC newbie who came from a HyperCard background (kind of dates it doesn't it? LOL).
Almost every helper on this list came from HC. I thought I was the oldest. I am not.

The short experiment I mentioned will take you ten minutes, and then you will be an expert. I assume you know how to set a custom property, even if you never have.

1- "set the changeColor of btn 1 to "true". Yep, this is all you need, and no different than setting any other property. But like a variable, it is both created and loaded on the fly.

2- In the property inspector of a control, choose the "custom" pane, add the property ("add new element") and set its value. Again, pretty much like any other property.

Craig

Post Reply