Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » How to trigger the "Print" action of a Browser?
How to trigger the "Print" action of a Browser? [message #884274] Sun, 10 June 2012 13:38 Go to next message
John Lussmyer is currently offline John Lussmyer
Messages: 96
Registered: December 2010
Member
I have a View that contains a Browser.
The Browser supports Print via it's Right-Click popup menu.
I'd like to have my "Print" button elsewhere in the view cause the Browser to invoke it's Print.

Is that possible?

Re: How to trigger the "Print" action of a Browser? [message #884313 is a reply to message #884274] Sun, 10 June 2012 15:33 Go to previous messageGo to next message
Simon Scholz is currently offline Simon Scholz
Messages: 73
Registered: April 2012
Location: Germany
Member
Hello "Missing name Mising name" Smile,

yes it is possible...

I just created a sample application for you, so that you´re able to print my answer with it (browser.setUrl aims to this forum thread Razz)

		final Browser browser = new Browser(parent, SWT.NONE);
		browser.setUrl("www.eclipse.org/forums/index.php/t/360700/");

		Button button = new Button(parent, SWT.PUSH);
		button.setText("Print");
		button.addSelectionListener(new SelectionAdapter() {

			@Override
			public void widgetSelected(SelectionEvent e) {
				boolean execute = browser.execute("window.print()");
				if (execute) {
					System.out.println("print dialog should appear.");
				} else {
					System.out.println("javascript could not be executed.");
				}
			}

		});


Best regards,

Simon
Re: How to trigger the "Print" action of a Browser? [message #884379 is a reply to message #884313] Sun, 10 June 2012 20:20 Go to previous message
John Lussmyer is currently offline John Lussmyer
Messages: 96
Registered: December 2010
Member
Thanks, it just never occurred to me to use javascript to do it!

(Sure wish I could fix the "Missing Name" mess, something seems to be hosed up with the userid handling in this forum.)
Previous Topic:Trying to get CSS styling working on 3.x
Next Topic:RCP + JavaSriptEditor
Goto Forum:
  


Current Time: Fri Aug 29 08:22:29 EDT 2014

Powered by FUDForum. Page generated in 0.01646 seconds