Is it possible to make a "print" button?


#1

Hello everyone, I’m a complete Hype newbie, so I tried to find an answer in the manual and the forums first. As I came up with no results, here’s my question.
I’d love to make some educational quizzes with Hype, for example gap texts. Would it be possible to let the students print their current text? So basically a “send current screen contents to printer” function?

Thanks in advance for your answer(s)
Anke


(Greg) #2

This script could work…

 window.print()

#3

Yes, you would run the following JavaScript ‘on mouse click’ when clicking a ‘print button’:

Select the button, click the ‘Action Inspector’ and create a Mouse Click action to Run a JavaScript, then paste that in. Some browsers are not very intelligent when printing, so it really comes down to the quality of the browser’s print renderer.


#4

Thank you, I’ll try that. Seems easy enough :smile:

Greetings from Germany
Anke


(marcomiana) #5

ok, but it’s possible to use a css for print formatted page?


(Nick ) #6

Not really as the print protocol is based on the browser. So all you are doing is passing the command to the browser to "open it’s print dialogue window"
There used to be some sketchy ways to do this with VBScript acting on an iFrame button for IE but Microsoft shut that down since it could be a security breach.


(marcomiana) #7

I think that would be a good idea to use the hype "layout"function to do a print size that uses a dedicated css (like this html tag type=“text/css” media=“print”). What do you think?


(Nick ) #8

Try it out, that might be a neat application…and share :smile:


(Braulio Elizondo) #9

Hello.
I have a question. It posible use this script in a scene with images?


(Loves Hype) #10

Just assign a click functionality to a image and then chose JavaScript. Enter the window.print() in an new function.


(Braulio Elizondo) #11

Excellent, this script works perfect, thanks for your help Max, regards.


#12

I haven’t used this for printing, so I’m not sure, but maybe CSS Media Queries is what you’re looking for…

https://www.w3schools.com/css/css3_mediaqueries.asp


(Mark Hunte) #13

Pretty sure I used this in the past and it worked well.

The idea is to set specific styles when printing.

i.e

@media print { 
 
 .noShowPrint { display: none !important; } 
}