Anthony Richir
Anthony Richir

Reputation: 649

Disable spell check in SWT Browser widget

I'm working on an Eclipse based application in which we use a Browser widget. When typing text in this widget, a spell check is executed. We would like to deactivate it.

Is it possible ?

Upvotes: 2

Views: 242

Answers (1)

Rüdiger Herrmann
Rüdiger Herrmann

Reputation: 20985

If you have control over the page that is displayed, you can simply disable spell checking by setting the appropriate attribute(s) (see Disable spell-checking on HTML textfields). But I think you wouldn't have asked if that was the case...

If however the page is loaded from elsewhere you need to let the browser widget execute Javascript code that disables spell checking after the page is fully loaded.

The snippet below uses a ProgressListener to that is called when the page has been loaded completely. The Javascript that then gets executed is off the top of my head and may need refinement.

Browser browser = new Browser( parent, SWT.NONE );
browser.addProgressListener( new ProgressAdapter() {
  public void completed( ProgressEvent event ) {
    browser.execute( "document.getElementsByTagName( 'html' )[ 0 ].spellcheck = false;" );
  }
} );
browser.setUrl( ... );

Upvotes: 1

Related Questions