OS print dialog

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Scott Richardson
Posts: 34
Joined: Mon May 08, 2006 7:02 pm

OS print dialog

Post by Scott Richardson » Wed Feb 04, 2009 4:20 pm

When using

answer printer

to call up a standard OS print dialog by clicking a button, is there something else I need to do to get the "cancel" button (in the OS dialog) to function if a user decides not to print? I may be misunderstanding the user guide when it talks about using

answer printer

instead of one of the custom print libraries. Everything works great and just as it supposed to with the exception of the "cancel" button — it prints instead, just like the "print" button. I have tried a few different approaches in the script for the button (like, if the result is "cancel" then cancel printing, etc.), but this didn't work.

By the way, I don't think the custom printing features will work in this particular situation. I am not printing cards, fields, or images. I am printing snapshots of groups contained on cards.

I am new to the printing features, since none of previous projects required printing, so I am sorry if this is a dumb question. I would really appreciate any tips to help me understand this particular issue.

Thanks,
Scott

gyroscope
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 404
Joined: Tue Jan 08, 2008 3:44 pm
Contact:

Post by gyroscope » Wed Feb 04, 2009 5:56 pm

Hi Scott

I might be able to shed a little light here:

If you use this code:

Code: Select all

"revShowPrintDialog false, true
revPrintField the name of field "FieldAll"
THen you get the correct print dialog with a cancel button.

Obviously, the above prints a field; if you want to print a snapshot of a set of controls, I'm guessing you have to use

Code: Select all

revPrintField the name of image "your group image"
I haven't tried this, and a more experienced Revver might correct me, and anyhow, this would only work if you know the name of the snapshot...

A snapshot is an image, surely? My little time dealing with snapshots is that there's no way of naming the snapshot (not that I could find) or even finding the name automatically given when the snapshot is made.

So there we are, a little light, and a bit of mud... :wink:

:)

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4171
Joined: Sun Jan 07, 2007 9:12 pm

Post by bn » Wed Feb 04, 2009 9:16 pm

My little time dealing with snapshots is that there's no way of naming the snapshot (not that I could find) or even finding the name automatically given when the snapshot is made.
If you import a snapshot it is an image, and you address it as 'last image' right after you did the snapshot. So

Code: Select all

set the name of last image to "myImage"
names the snapshot then print (I never printed an image out of Rev, so I am of little help here)
lock screen
set the paintcompression to "PNG"
import snapshot from image "i1"
set the name of last image to "imageForPrint"
hide image "imageForPrint"
unlock screen
lets you import the snapshot invisibly
regards
Bernd

gyroscope
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 404
Joined: Tue Jan 08, 2008 3:44 pm
Contact:

Post by gyroscope » Wed Feb 04, 2009 9:52 pm

Thank you for that info Bernd, helpful as always.

:)

Scott Richardson
Posts: 34
Joined: Mon May 08, 2006 7:02 pm

Post by Scott Richardson » Wed Feb 04, 2009 10:31 pm

Thanks for the replies to my problem. The information is useful, but I am still stuck. None of the custom print libraries in Rev [revShow..., revPrint...] functions exactly the way I need it to. I can get those to work when I am printing a field or a card, etc., but when printing overlapping images (some visible and some invisible) as a group, it doesn't print as it should. It only prints part of the images of the group (usually the rearmost layer). Using

Code: Select all

answer printer
gets me the standard OS dialog where everything is functional [copies, collate, etc.] and it prints great. It is all fine except the "cancel" button. It looks functional and I can click it, but it acts the same as the "print" button in both Windows and Mac platforms — not canceling anything, but going on to process and print the image.

I have no problems printing the snapshots of the image groups, just no way to "not" print them if the user changes his mind.

The User Guide says:
Use the answer printer command to display a standard printer dialog prior to printing. If the user cancels the dialog, "cancel" will be returned by the result function.
What else am I missing?

Thanks again,
Scott

sims
Posts: 43
Joined: Wed Apr 12, 2006 5:36 pm

Post by sims » Thu Feb 05, 2009 4:50 am

" It is all fine except the "cancel" button. It looks functional and I can click it, but it acts the same as the "print" button in both Windows and Mac platforms — not canceling anything, but going on to process and print the image. "

I haven't been following this but - a while back I wrote a printing 'thang' for an app and recollect using: if it is "Cancel" then exit

I had to change that to "result" INSTEAD of "it" for the script to work, or so I recollect. The old brain cells might be deceiving me on this however ;-)

Klaus
Posts: 14189
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Post by Klaus » Thu Feb 05, 2009 9:22 am

Hi Scott,
maybe this little snippet will help:

Code: Select all

on mouseup

    ## Show page setup Dialog
    answer page setup
    if the result = "cancel" then
      exit mouseup
    end if
    
    ## Show printer dialog
    answer printer
    if the result = "cancel" then
      exit mouseup
    end if

   ## Finally do your printing...
end mouseup
Hope that helps.


Best

Klaus

Scott Richardson
Posts: 34
Joined: Mon May 08, 2006 7:02 pm

Post by Scott Richardson » Thu Feb 05, 2009 11:41 pm

Thanks everyone. With all of the suggestions and help, I figured out what was wrong. I did have a word wrong in my "if ... then" section, but even fixing that didn't completely solve the problem. What did finally fix it was when I noticed that I had one line out of place. In moving things around in the script, I had left the line setting the print margins before my "if ... then" line. This is what threw everything off.

For future users just beginning to experiment with printing, be sure to keep all instructions to the printer after the "if ... then" for canceling.

Thanks again everyone,
Scott

Post Reply