Text

Instances of this class are selectable user interface objects that allow the user to enter and modify text. Text controls can be either single or multi-line. When a text control is created with a border, the operating system includes a platform specific inset around the contents of the control. When created without a border, an effort is made to remove the inset such that the preferred size of the control is the same size as the contents. <p> <dl> <dt><b>Styles:</b></dt> <dd>CANCEL, CENTER, LEFT, MULTI, PASSWORD, SEARCH, SINGLE, RIGHT, READ_ONLY, WRAP</dd> <dt><b>Events:</b></dt> <dd>DefaultSelection, Modify, Verify</dd> </dl> <p> Note: Only one of the styles MULTI and SINGLE may be specified, and only one of the styles LEFT, CENTER, and RIGHT may be specified. </p><p> IMPORTANT: This class is <em>not</em> intended to be subclassed. </p>

@see <a href="http://www.eclipse.org/swt/snippets/#text">Text snippets</a> @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a> @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>

class Text : Scrollable {}

Constructors

this
this(Composite parent, int style)

Constructs a new instance of this class given its parent and a style value describing its behavior and appearance. <p> The style value is either one of the style constants defined in class <code>SWT</code> which is applicable to instances of this class, or must be built by <em>bitwise OR</em>'ing together (that is, using the <code>int</code> "|" operator) two or more of those <code>SWT</code> style constants. The class description lists the style constants that are applicable to the class. Style bits are also inherited from superclasses. </p>

Members

Aliases

computeSize
alias computeSize = Scrollable.computeSize
Undocumented in source.
dragDetect
alias dragDetect = Scrollable.dragDetect
Undocumented in source.
setBackgroundColor
alias setBackgroundColor = Scrollable.setBackgroundColor
Undocumented in source.
setCursor
alias setCursor = Scrollable.setCursor
Undocumented in source.
setOrientation
alias setOrientation = Scrollable.setOrientation
Undocumented in source.
translateTraversal
alias translateTraversal = Scrollable.translateTraversal
Undocumented in source.

Functions

addModifyListener
void addModifyListener(ModifyListener listener)

Adds the listener to the collection of listeners who will be notified when the receiver's text is modified, by sending it one of the messages defined in the <code>ModifyListener</code> interface.

addSelectionListener
void addSelectionListener(SelectionListener listener)

Adds the listener to the collection of listeners who will be notified when the control is selected by the user, by sending it one of the messages defined in the <code>SelectionListener</code> interface. <p> <code>widgetSelected</code> is not called for texts. <code>widgetDefaultSelected</code> is typically called when ENTER is pressed in a single-line text, or when ENTER is pressed in a search text. If the receiver has the <code>SWT.SEARCH | SWT.CANCEL</code> style and the user cancels the search, the event object detail field contains the value <code>SWT.CANCEL</code>. </p>

addVerifyListener
void addVerifyListener(VerifyListener listener)

Adds the listener to the collection of listeners who will be notified when the receiver's text is verified, by sending it one of the messages defined in the <code>VerifyListener</code> interface.

append
void append(String string)

Appends a string. <p> The new text is appended to the text at the end of the widget. </p>

clearSelection
void clearSelection()

Clears the selection.

computeSize
Point computeSize(int wHint, int hHint, bool changed)
Undocumented in source. Be warned that the author may not have intended to support it.
computeTrim
Rectangle computeTrim(int x, int y, int width, int height)
Undocumented in source. Be warned that the author may not have intended to support it.
copy
void copy()

Copies the selected text. <p> The current selection is copied to the clipboard. </p>

createHandle
void createHandle(int index)
Undocumented in source. Be warned that the author may not have intended to support it.
createWidget
void createWidget(int index)
Undocumented in source. Be warned that the author may not have intended to support it.
cut
void cut()

Cuts the selected text. <p> The current selection is first copied to the clipboard and then deleted from the widget. </p>

deregister
void deregister()
Undocumented in source. Be warned that the author may not have intended to support it.
dragDetect
bool dragDetect(int x, int y, bool filter, bool* consume)
Undocumented in source. Be warned that the author may not have intended to support it.
eventWindow
GdkDrawable* eventWindow()
Undocumented in source. Be warned that the author may not have intended to support it.
filterKey
bool filterKey(int keyval, GdkEventKey* event)
Undocumented in source. Be warned that the author may not have intended to support it.
fixIM
void fixIM()
Undocumented in source. Be warned that the author may not have intended to support it.
getBackgroundColor
GdkColor* getBackgroundColor()
Undocumented in source. Be warned that the author may not have intended to support it.
getBorderWidth
int getBorderWidth()
Undocumented in source. Be warned that the author may not have intended to support it.
getCaretLineNumber
int getCaretLineNumber()

Returns the line number of the caret. <p> The line number of the caret is returned. </p>

getCaretLocation
Point getCaretLocation()

Returns a point describing the receiver's location relative to its parent (or its display if its parent is null). <p> The location of the caret is returned. </p>

getCaretPosition
int getCaretPosition()

Returns the character position of the caret. <p> Indexing is zero based. </p>

getCharCount
int getCharCount()

Returns the number of characters.

getDoubleClickEnabled
bool getDoubleClickEnabled()

Returns the double click enabled flag. <p> The double click flag enables or disables the default action of the text widget when the user double clicks. </p>

getEchoChar
char getEchoChar()

Returns the echo character. <p> The echo character is the character that is displayed when the user enters text or the text is changed by the programmer. </p>

getEditable
bool getEditable()

Returns the editable state.

getForegroundColor
GdkColor* getForegroundColor()
Undocumented in source. Be warned that the author may not have intended to support it.
getLineCount
int getLineCount()

Returns the number of lines.

getLineDelimiter
String getLineDelimiter()

Returns the line delimiter.

getLineHeight
int getLineHeight()

Returns the height of a line.

getMessage
String getMessage()

Returns the widget message. When the widget is created with the style <code>SWT.SEARCH</code>, the message text is displayed as a hint for the user, indicating the purpose of the field. <p> Note: This operation is a <em>HINT</em> and is not supported on platforms that do not have this concept. </p>

getOrientation
int getOrientation()

Returns the orientation of the receiver, which will be one of the constants <code>SWT.LEFT_TO_RIGHT</code> or <code>SWT.RIGHT_TO_LEFT</code>.

getPosition
int getPosition(Point point)
Undocumented in source. Be warned that the author may not have intended to support it.
getSelection
Point getSelection()

Returns a <code>Point</code> whose x coordinate is the character position representing the start of the selected text, and whose y coordinate is the character position representing the end of the selection. An "empty" selection is indicated by the x and y coordinates having the same value. <p> Indexing is zero based. The range of a selection is from 0..N where N is the number of characters in the widget. </p>

getSelectionCount
int getSelectionCount()

Returns the number of selected characters.

getSelectionText
String getSelectionText()

Gets the selected text, or an empty string if there is no current selection.

getTabWidth
int getTabWidth(int tabs)
Undocumented in source. Be warned that the author may not have intended to support it.
getTabs
int getTabs()

Returns the number of tabs. <p> Tab stop spacing is specified in terms of the space (' ') character. The width of a single tab stop is the pixel width of the spaces. </p>

getText
String getText()

Returns the widget text. <p> The text for a text widget is the characters in the widget, or an empty string if this has never been set. </p>

getText
String getText(int start, int end)

Returns a range of text. Returns an empty string if the start of the range is greater than the end. <p> Indexing is zero based. The range of a selection is from 0..N-1 where N is the number of characters in the widget. </p>

getTextLimit
int getTextLimit()

Returns the maximum number of characters that the receiver is capable of holding. <p> If this has not been changed by <code>setTextLimit()</code>, it will be the constant <code>Text.LIMIT</code>. </p>

getTopIndex
int getTopIndex()

Returns the zero-relative index of the line which is currently at the top of the receiver. <p> This index can change when lines are scrolled or new lines are added or removed. </p>

getTopPixel
int getTopPixel()

Returns the top pixel. <p> The top pixel is the pixel position of the line that is currently at the top of the widget. On some platforms, a text widget can be scrolled by pixels instead of lines so that a partial line is displayed at the top of the widget. </p><p> The top pixel changes when the widget is scrolled. The top pixel does not include the widget trimming. </p>

gtk_activate
int gtk_activate(GtkWidget* widget)
Undocumented in source. Be warned that the author may not have intended to support it.
gtk_button_press_event
int gtk_button_press_event(GtkWidget* widget, GdkEventButton* gdkEvent)
Undocumented in source. Be warned that the author may not have intended to support it.
gtk_changed
int gtk_changed(GtkWidget* widget)
Undocumented in source. Be warned that the author may not have intended to support it.
gtk_commit
int gtk_commit(GtkIMContext* imcontext, char* text)
Undocumented in source. Be warned that the author may not have intended to support it.
gtk_delete_range
int gtk_delete_range(GtkWidget* widget, ptrdiff_t iter1, ptrdiff_t iter2)
Undocumented in source. Be warned that the author may not have intended to support it.
gtk_delete_text
int gtk_delete_text(GtkWidget* widget, ptrdiff_t start_pos, ptrdiff_t end_pos)
Undocumented in source. Be warned that the author may not have intended to support it.
gtk_event_after
int gtk_event_after(GtkWidget* widget, GdkEvent* event)
Undocumented in source. Be warned that the author may not have intended to support it.
gtk_focus_out_event
int gtk_focus_out_event(GtkWidget* widget, GdkEventFocus* event)
Undocumented in source. Be warned that the author may not have intended to support it.
gtk_grab_focus
int gtk_grab_focus(GtkWidget* widget)
Undocumented in source. Be warned that the author may not have intended to support it.
gtk_insert_text
int gtk_insert_text(GtkEditable* widget, char* new_text, ptrdiff_t new_text_length, ptrdiff_t position)
Undocumented in source. Be warned that the author may not have intended to support it.
gtk_key_press_event
int gtk_key_press_event(GtkWidget* widget, GdkEventKey* event)
Undocumented in source. Be warned that the author may not have intended to support it.
gtk_populate_popup
int gtk_populate_popup(GtkWidget* widget, GtkWidget* menu)
Undocumented in source. Be warned that the author may not have intended to support it.
gtk_setCursor
void gtk_setCursor(GdkCursor* cursor)
Undocumented in source. Be warned that the author may not have intended to support it.
gtk_text_buffer_insert_text
int gtk_text_buffer_insert_text(GtkTextBuffer* widget, GtkTextIter* iter, char* text, ptrdiff_t len)
Undocumented in source. Be warned that the author may not have intended to support it.
hookEvents
void hookEvents()
Undocumented in source. Be warned that the author may not have intended to support it.
imContext
GtkIMContext* imContext()
Undocumented in source. Be warned that the author may not have intended to support it.
insert
void insert(String string)

Inserts a string. <p> The old selection is replaced with the new text. </p>

paintWindow
GdkDrawable* paintWindow()
Undocumented in source. Be warned that the author may not have intended to support it.
paste
void paste()

Pastes text from clipboard. <p> The selected text is deleted from the widget and new text inserted from the clipboard. </p>

register
void register()
Undocumented in source. Be warned that the author may not have intended to support it.
releaseWidget
void releaseWidget()
Undocumented in source. Be warned that the author may not have intended to support it.
removeModifyListener
void removeModifyListener(ModifyListener listener)

Removes the listener from the collection of listeners who will be notified when the receiver's text is modified.

removeSelectionListener
void removeSelectionListener(SelectionListener listener)

Removes the listener from the collection of listeners who will be notified when the control is selected by the user.

removeVerifyListener
void removeVerifyListener(VerifyListener listener)

Removes the listener from the collection of listeners who will be notified when the control is verified.

selectAll
void selectAll()

Selects all the text in the receiver.

setBackgroundColor
void setBackgroundColor(GdkColor* color)
Undocumented in source. Be warned that the author may not have intended to support it.
setDoubleClickEnabled
void setDoubleClickEnabled(bool doubleClick)

Sets the double click enabled flag. <p> The double click flag enables or disables the default action of the text widget when the user double clicks. </p><p> Note: This operation is a hint and is not supported on platforms that do not have this concept. </p>

setEchoChar
void setEchoChar(char echo)

Sets the echo character. <p> The echo character is the character that is displayed when the user enters text or the text is changed by the programmer. Setting the echo character to '\0' clears the echo character and redraws the original text. If for any reason the echo character is invalid, or if the platform does not allow modification of the echo character, the default echo character for the platform is used. </p>

setEditable
void setEditable(bool editable)

Sets the editable state.

setFontDescription
void setFontDescription(PangoFontDescription* font)
Undocumented in source. Be warned that the author may not have intended to support it.
setMessage
void setMessage(String message)

Sets the widget message. When the widget is created with the style <code>SWT.SEARCH</code>, the message text is displayed as a hint for the user, indicating the purpose of the field. <p> Note: This operation is a <em>HINT</em> and is not supported on platforms that do not have this concept. </p>

setOrientation
void setOrientation(int orientation)

Sets the orientation of the receiver, which must be one of the constants <code>SWT.LEFT_TO_RIGHT</code> or <code>SWT.RIGHT_TO_LEFT</code>. <p> Note: This operation is a hint and is not supported on platforms that do not have this concept. </p>

setSelection
void setSelection(int start)

Sets the selection. <p> Indexing is zero based. The range of a selection is from 0..N where N is the number of characters in the widget. </p><p> Text selections are specified in terms of caret positions. In a text widget that contains N characters, there are N+1 caret positions, ranging from 0..N. This differs from other functions that address character position such as getText () that use the regular array indexing rules. </p>

setSelection
void setSelection(int start, int end)

Sets the selection to the range specified by the given start and end indices. <p> Indexing is zero based. The range of a selection is from 0..N where N is the number of characters in the widget. </p><p> Text selections are specified in terms of caret positions. In a text widget that contains N characters, there are N+1 caret positions, ranging from 0..N. This differs from other functions that address character position such as getText () that use the usual array indexing rules. </p>

setSelection
void setSelection(Point selection)

Sets the selection to the range specified by the given point, where the x coordinate represents the start index and the y coordinate represents the end index. <p> Indexing is zero based. The range of a selection is from 0..N where N is the number of characters in the widget. </p><p> Text selections are specified in terms of caret positions. In a text widget that contains N characters, there are N+1 caret positions, ranging from 0..N. This differs from other functions that address character position such as getText () that use the usual array indexing rules. </p>

setTabStops
void setTabStops(int tabs)
Undocumented in source. Be warned that the author may not have intended to support it.
setTabs
void setTabs(int tabs)

Sets the number of tabs. <p> Tab stop spacing is specified in terms of the space (' ') character. The width of a single tab stop is the pixel width of the spaces. </p>

setText
void setText(String string)

Sets the contents of the receiver to the given string. If the receiver has style SINGLE and the argument contains multiple lines of text, the result of this operation is undefined and may vary from platform to platform.

setTextLimit
void setTextLimit(int limit)

Sets the maximum number of characters that the receiver is capable of holding to be the argument. <p> Instead of trying to set the text limit to zero, consider creating a read-only text widget. </p><p> To reset this value to the default, use <code>setTextLimit(Text.LIMIT)</code>. Specifying a limit value larger than <code>Text.LIMIT</code> sets the receiver's limit to <code>Text.LIMIT</code>. </p>

setTopIndex
void setTopIndex(int index)

Sets the zero-relative index of the line which is currently at the top of the receiver. This index can change when lines are scrolled or new lines are added and removed.

showSelection
void showSelection()

Shows the selection. <p> If the selection is already showing in the receiver, this method simply returns. Otherwise, lines are scrolled until the selection is visible. </p>

translateTraversal
bool translateTraversal(GdkEventKey* keyEvent)
Undocumented in source. Be warned that the author may not have intended to support it.
traversalCode
int traversalCode(int key, GdkEventKey* event)
Undocumented in source. Be warned that the author may not have intended to support it.
verifyText
String verifyText(String string, int start, int end)
Undocumented in source. Be warned that the author may not have intended to support it.

Static functions

checkStyle
int checkStyle(int style)
Undocumented in source. Be warned that the author may not have intended to support it.

Static variables

DELIMITER
String DELIMITER;

The delimiter used by multi-line text widgets. When text is queried and from the widget, it will be delimited using this delimiter.

INNER_BORDER
int INNER_BORDER;
Undocumented in source.
LIMIT
int LIMIT;

The maximum number of characters that can be entered into a text widget. <p> Note that this value is platform dependent, based upon the native widget implementation. </p>

Variables

bufferHandle
GtkTextBuffer* bufferHandle;
Undocumented in source.
doubleClick
bool doubleClick;
fixEnd
int fixEnd;
Undocumented in source.
fixStart
int fixStart;
Undocumented in source.
gdkEventKey
GdkEventKey* gdkEventKey;
lastEventTime
int lastEventTime;
Undocumented in source.
message
String message;
Undocumented in source.
tabs
int tabs;
Undocumented in source.

Inherited Members

From Scrollable

scrolledHandle
GtkWidget* scrolledHandle;
Undocumented in source.
horizontalBar
ScrollBar horizontalBar;
verticalBar
ScrollBar verticalBar;
Undocumented in source.
clientHandle
GtkWidget* clientHandle()
Undocumented in source. Be warned that the author may not have intended to support it.
computeTrim
Rectangle computeTrim(int x, int y, int width, int height)

Given a desired <em>client area</em> for the receiver (as described by the arguments), returns the bounding rectangle which would be required to produce that client area. <p> In other words, it returns a rectangle such that, if the receiver's bounds were set to that rectangle, the area of the receiver which is capable of displaying data (that is, not covered by the "trimmings") would be the rectangle described by the arguments (relative to the receiver's parent). </p>

createScrollBar
ScrollBar createScrollBar(int style)
Undocumented in source. Be warned that the author may not have intended to support it.
createWidget
void createWidget(int index)
Undocumented in source. Be warned that the author may not have intended to support it.
deregister
void deregister()
Undocumented in source. Be warned that the author may not have intended to support it.
destroyScrollBar
void destroyScrollBar(ScrollBar bar)
Undocumented in source. Be warned that the author may not have intended to support it.
getBorderWidth
int getBorderWidth()
Undocumented in source. Be warned that the author may not have intended to support it.
getClientArea
Rectangle getClientArea()

Returns a rectangle which describes the area of the receiver which is capable of displaying data (that is, not covered by the "trimmings").

getHorizontalBar
ScrollBar getHorizontalBar()

Returns the receiver's horizontal scroll bar if it has one, and null if it does not.

getVerticalBar
ScrollBar getVerticalBar()

Returns the receiver's vertical scroll bar if it has one, and null if it does not.

gtk_scroll_event
int gtk_scroll_event(GtkWidget* widget, GdkEventScroll* eventPtr)
Undocumented in source. Be warned that the author may not have intended to support it.
hScrollBarWidth
int hScrollBarWidth()
Undocumented in source. Be warned that the author may not have intended to support it.
sendLeaveNotify
bool sendLeaveNotify()
Undocumented in source. Be warned that the author may not have intended to support it.
setOrientation
void setOrientation()
Undocumented in source. Be warned that the author may not have intended to support it.
setScrollBarVisible
bool setScrollBarVisible(ScrollBar bar, bool visible)
Undocumented in source. Be warned that the author may not have intended to support it.
redrawBackgroundImage
void redrawBackgroundImage()
Undocumented in source. Be warned that the author may not have intended to support it.
redrawWidget
void redrawWidget(int x, int y, int width, int height, bool redrawAll, bool all, bool trim)
Undocumented in source. Be warned that the author may not have intended to support it.
register
void register()
Undocumented in source. Be warned that the author may not have intended to support it.
releaseHandle
void releaseHandle()
Undocumented in source. Be warned that the author may not have intended to support it.
releaseChildren
void releaseChildren(bool destroy)
Undocumented in source. Be warned that the author may not have intended to support it.
resizeHandle
void resizeHandle(int width, int height)
Undocumented in source. Be warned that the author may not have intended to support it.
showWidget
void showWidget()
Undocumented in source. Be warned that the author may not have intended to support it.
topHandle
GtkWidget* topHandle()
Undocumented in source. Be warned that the author may not have intended to support it.
updateScrollBarValue
void updateScrollBarValue(ScrollBar bar)
Undocumented in source. Be warned that the author may not have intended to support it.
vScrollBarWidth
int vScrollBarWidth()
Undocumented in source. Be warned that the author may not have intended to support it.

Meta