public class

RichTextArea

extends FocusWidget
implements HasInitializeHandlers HasSafeHtml HasHTML
java.lang.Object
   ↳ com.google.gwt.user.client.ui.UIObject
     ↳ com.google.gwt.user.client.ui.Widget
       ↳ com.google.gwt.user.client.ui.FocusWidget
         ↳ com.google.gwt.user.client.ui.RichTextArea

Class Overview

A rich text editor that allows complex styling and formatting. Because some browsers do not support rich text editing, and others support only a limited subset of functionality, there are two formatter interfaces, accessed via getBasicFormatter() and getExtendedFormatter() . A browser that does not support rich text editing at all will return null for both of these, while one that supports only the basic functionality will return null for the latter.

CSS Style Rules

.gwt-RichTextArea
Applied to the rich text element.

Summary

Nested Classes
interface RichTextArea.BasicFormatter This interface is deprecated. use RichTextArea.Formatter instead  
interface RichTextArea.ExtendedFormatter This interface is deprecated. use RichTextArea.Formatter instead  
class RichTextArea.FontSize Font size enumeration. 
interface RichTextArea.Formatter

This interface is used to access full formatting options, when available. 

class RichTextArea.Justification Justification enumeration. 
[Expand]
Inherited Constants
From class com.google.gwt.user.client.ui.UIObject
Public Constructors
RichTextArea()
Creates a new, blank RichTextArea object with no stylesheet.
Public Methods
HandlerRegistration addInitializeHandler(InitializeHandler handler)
Adds an InitializeEvent handler.
RichTextArea.BasicFormatter getBasicFormatter()
This method is deprecated. use getFormatter() instead
RichTextArea.ExtendedFormatter getExtendedFormatter()
This method is deprecated. use getFormatter() instead
RichTextArea.Formatter getFormatter()
Gets the rich text formatting interface.
String getHTML()
Gets this object's contents as HTML.
String getText()
Gets this object's text.
boolean isEnabled()
Gets whether this widget is enabled.
void setEnabled(boolean enabled)
Sets whether this widget is enabled.
void setFocus(boolean focused)
Explicitly focus/unfocus this widget.
void setHTML(SafeHtml html)
Sets this object's contents via known-safe HTML.
void setHTML(String html)
Sets this object's contents via HTML.
void setText(String text)
Sets this object's text.
Protected Methods
void onAttach()

This method is called when a widget is attached to the browser's document.

void onDetach()

This method is called when a widget is detached from the browser's document.

[Expand]
Inherited Methods
From class com.google.gwt.user.client.ui.FocusWidget
From class com.google.gwt.user.client.ui.Widget
From class com.google.gwt.user.client.ui.UIObject
From class java.lang.Object
From interface com.google.gwt.event.dom.client.HasBlurHandlers
From interface com.google.gwt.event.dom.client.HasClickHandlers
From interface com.google.gwt.event.dom.client.HasDoubleClickHandlers
From interface com.google.gwt.event.dom.client.HasFocusHandlers
From interface com.google.gwt.event.dom.client.HasGestureChangeHandlers
From interface com.google.gwt.event.dom.client.HasGestureEndHandlers
From interface com.google.gwt.event.dom.client.HasGestureStartHandlers
From interface com.google.gwt.event.dom.client.HasKeyDownHandlers
From interface com.google.gwt.event.dom.client.HasKeyPressHandlers
From interface com.google.gwt.event.dom.client.HasKeyUpHandlers
From interface com.google.gwt.event.dom.client.HasMouseDownHandlers
From interface com.google.gwt.event.dom.client.HasMouseMoveHandlers
From interface com.google.gwt.event.dom.client.HasMouseOutHandlers
From interface com.google.gwt.event.dom.client.HasMouseOverHandlers
From interface com.google.gwt.event.dom.client.HasMouseUpHandlers
From interface com.google.gwt.event.dom.client.HasMouseWheelHandlers
From interface com.google.gwt.event.dom.client.HasTouchCancelHandlers
From interface com.google.gwt.event.dom.client.HasTouchEndHandlers
From interface com.google.gwt.event.dom.client.HasTouchMoveHandlers
From interface com.google.gwt.event.dom.client.HasTouchStartHandlers
From interface com.google.gwt.event.logical.shared.HasAttachHandlers
From interface com.google.gwt.event.logical.shared.HasInitializeHandlers
From interface com.google.gwt.event.shared.HasHandlers
From interface com.google.gwt.safehtml.client.HasSafeHtml
From interface com.google.gwt.user.client.EventListener
From interface com.google.gwt.user.client.ui.Focusable
From interface com.google.gwt.user.client.ui.HasEnabled
From interface com.google.gwt.user.client.ui.HasHTML
From interface com.google.gwt.user.client.ui.HasText
From interface com.google.gwt.user.client.ui.IsWidget
From interface com.google.gwt.user.client.ui.SourcesClickEvents
From interface com.google.gwt.user.client.ui.SourcesFocusEvents
From interface com.google.gwt.user.client.ui.SourcesKeyboardEvents
From interface com.google.gwt.user.client.ui.SourcesMouseEvents

Public Constructors

public RichTextArea ()

Creates a new, blank RichTextArea object with no stylesheet.

Public Methods

public HandlerRegistration addInitializeHandler (InitializeHandler handler)

Adds an InitializeEvent handler.

Parameters
handler the handler
Returns
  • the registration for the event

public RichTextArea.BasicFormatter getBasicFormatter ()

This method is deprecated.
use getFormatter() instead

Gets the basic rich text formatting interface. Note that formatting can only be done when the RichTextArea is attached, visible on the page, and has been focused by the user.

Returns
  • null if basic formatting is not supported

public RichTextArea.ExtendedFormatter getExtendedFormatter ()

This method is deprecated.
use getFormatter() instead

Gets the full rich text formatting interface. Note that formatting can only be done when the RichTextArea is attached, visible on the page, and has been focused by the user.

Returns
  • null if full formatting is not supported

public RichTextArea.Formatter getFormatter ()

Gets the rich text formatting interface. Note that formatting can only be done when the RichTextArea is attached, visible on the page, and has been focused by the user.

Returns
  • null if full formatting is not supported

public String getHTML ()

Gets this object's contents as HTML.

Returns
  • the object's HTML

public String getText ()

Gets this object's text.

Returns
  • the object's text

public boolean isEnabled ()

Gets whether this widget is enabled.

Returns
  • true if the widget is enabled

public void setEnabled (boolean enabled)

Sets whether this widget is enabled.

Parameters
enabled true to enable the widget, false to disable it

public void setFocus (boolean focused)

Explicitly focus/unfocus this widget. Only one widget can have focus at a time, and the widget that does will receive all keyboard events.

Parameters
focused whether this widget should take focus or release it

public void setHTML (SafeHtml html)

Sets this object's contents via known-safe HTML.

The object will behave exactly the same as when a widget's setHTML(String) method is invoked; however the SafeHtml passed to this method observes the contract that it can be used in an HTML context without causing unsafe script execution. Thus, unlike setHTML(String), using this method cannot result in Cross-Site Scripting security vulnerabilities.

Parameters
html the object's new HTML, represented as a SafeHtml object

public void setHTML (String html)

Sets this object's contents via HTML. Use care when setting an object's HTML; it is an easy way to expose script-based security problems. Consider using setText(String) whenever possible.

Parameters
html the object's new HTML

public void setText (String text)

Sets this object's text.

Parameters
text the object's new text

Protected Methods

protected void onAttach ()

This method is called when a widget is attached to the browser's document. To receive notification after a Widget has been added to the document, override the onLoad() method or use addAttachHandler(AttachEvent.Handler).

It is strongly recommended that you override onLoad() or doAttachChildren() instead of this method to avoid inconsistencies between logical and physical attachment states.

Subclasses that override this method must call super.onAttach() to ensure that the Widget has been attached to its underlying Element.

protected void onDetach ()

This method is called when a widget is detached from the browser's document. To receive notification before a Widget is removed from the document, override the onUnload() method or use addAttachHandler(AttachEvent.Handler).

It is strongly recommended that you override onUnload() or doDetachChildren() instead of this method to avoid inconsistencies between logical and physical attachment states.

Subclasses that override this method must call super.onDetach() to ensure that the Widget has been detached from the underlying Element. Failure to do so will result in application memory leaks due to circular references between DOM Elements and JavaScript objects.