Skip to main content


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 17:38 Go to next message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 105
Registered: December 2010
Senior 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 19:33 Go to previous messageGo to next message
Simon Scholz is currently offline Simon ScholzFriend
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] Mon, 11 June 2012 00:20 Go to previous message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 105
Registered: December 2010
Senior 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: Thu Sep 26 08:33:24 GMT 2024

Powered by FUDForum. Page generated in 0.02513 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top