Class Text
- All Implemented Interfaces:
Proxy
,Accessible
,AccessibleText
,Buildable
,ConstraintTarget
,Editable
GtkText
is the common implementation of single-line text editing
that is shared between Entry
, PasswordEntry
,
SpinButton
, and other widgets. In all of these, a GtkText
instance is used as the delegate for the Editable
implementation.
A large number of key bindings s supported by default. If the entered text is longer than the allocation of the widget, the widget will scroll so that the cursor position is visible.
When using an entry for passwords and other sensitive information,
it can be put into “password mode” using setVisibility(boolean)
.
In this mode, entered text is displayed using an “invisible” character.
By default, GTK picks the best invisible character that is available
in the current font, but it can be changed with
setInvisibleChar(int)
.
If you want to add icons or progress display in an entry, look at
Entry
. There are other alternatives for more specialized
use cases, such as SearchEntry
.
If you need multi-line editable text, use TextView
.
Shortcuts and Gestures
GtkText
supports the following keyboard shortcuts:
Shift
+F10
orMenu
opens the context menu.Ctrl
+A
orCtrl
+/
selects all the text.Ctrl
+Shift
+A
orCtrl
+\
unselects all.Ctrl
+Z
undoes the last modification.Ctrl
+Y
orCtrl
+Shift
+Z
redoes the last undone modification.Ctrl
+Shift
+T
toggles the text direction.
Additionally, the following signals have default keybindings:
Gtk.Text::activate
Gtk.Text::backspace
Gtk.Text::copy-clipboard
Gtk.Text::cut-clipboard
Gtk.Text::delete-from-cursor
Gtk.Text::insert-emoji
Gtk.Text::move-cursor
Gtk.Text::paste-clipboard
Gtk.Text::toggle-overwrite
Actions
GtkText
defines a set of built-in actions:
clipboard.copy
copies the contents to the clipboard.clipboard.cut
copies the contents to the clipboard and deletes it from the widget.clipboard.paste
inserts the contents of the clipboard into the widget.menu.popup
opens the context menu.misc.insert-emoji
opens the Emoji chooser.misc.toggle-visibility
toggles theGtkText
:visibility property.misc.toggle-direction
toggles the text direction.selection.delete
deletes the current selection.selection.select-all
selects all of the widgets content.text.redo
redoes the last change to the contents.text.undo
undoes the last change to the contents.
CSS nodes
text[.read-only]
├── placeholder
├── undershoot.left
├── undershoot.right
├── [selection]
├── [cursor-handle[.top]
├── [cursor-handle.bottom]
├── [block-cursor]
├── [cursor-handle[.top/.bottom][.insertion-cursor]]
╰── [window.popup]
GtkText
has a main node with the name text
. Depending on the properties
of the widget, the .read-only
style class may appear.
When the entry has a selection, it adds a subnode with the name selection
.
When the entry is in overwrite mode, it adds a subnode with the name
block-cursor
that determines how the block cursor is drawn.
The CSS node for a context menu is added as a subnode with the name popup
.
The undershoot
nodes are used to draw the underflow indication when content
is scrolled out of view. These nodes get the .left
or .right
style class
added depending on where the indication is drawn.
When touch is used and touch selection handles are shown, they are using
CSS nodes with name cursor-handle
. They get the .top
or .bottom
style
class depending on where they are shown in relation to the selection. If
there is just a single handle for the text cursor, it gets the style class
.insertion-cursor
.
Accessibility
GtkText
uses the Gtk.AccessibleRole.none
role, which causes it to be
skipped for accessibility. This is because GtkText
is expected to be used
as a delegate for a GtkEditable
implementation that will be represented
to accessibility.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Functional interface declaration of theActivateCallback
callback.static interface
Functional interface declaration of theBackspaceCallback
callback.static class
Text.Builder<B extends Text.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static interface
Functional interface declaration of theCopyClipboardCallback
callback.static interface
Functional interface declaration of theCutClipboardCallback
callback.static interface
Functional interface declaration of theDeleteFromCursorCallback
callback.static interface
Functional interface declaration of theInsertAtCursorCallback
callback.static interface
Functional interface declaration of theInsertEmojiCallback
callback.static interface
Functional interface declaration of theMoveCursorCallback
callback.static interface
Functional interface declaration of thePasteClipboardCallback
callback.static interface
Functional interface declaration of thePreeditChangedCallback
callback.static interface
Functional interface declaration of theToggleOverwriteCallback
callback.Nested classes/interfaces inherited from class org.gnome.gtk.Widget
Widget.DestroyCallback, Widget.DirectionChangedCallback, Widget.HideCallback, Widget.KeynavFailedCallback, Widget.MapCallback, Widget.MnemonicActivateCallback, Widget.MoveFocusCallback, Widget.QueryTooltipCallback, Widget.RealizeCallback, Widget.ShowCallback, Widget.StateFlagsChangedCallback, Widget.UnmapCallback, Widget.UnrealizeCallback, Widget.WidgetClass, Widget.WidgetImpl
Nested classes/interfaces inherited from class org.gnome.gobject.InitiallyUnowned
InitiallyUnowned.InitiallyUnownedClass
Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
Nested classes/interfaces inherited from interface org.gnome.gtk.Accessible
Accessible.AccessibleImpl, Accessible.AccessibleInterface
Nested classes/interfaces inherited from interface org.gnome.gtk.AccessibleText
AccessibleText.AccessibleTextImpl, AccessibleText.AccessibleTextInterface
Nested classes/interfaces inherited from interface org.gnome.gtk.Buildable
Buildable.BuildableIface, Buildable.BuildableImpl
Nested classes/interfaces inherited from interface org.gnome.gtk.ConstraintTarget
ConstraintTarget.ConstraintTargetImpl, ConstraintTarget.ConstraintTargetInterface
Nested classes/interfaces inherited from interface org.gnome.gtk.Editable
Editable.ChangedCallback, Editable.DeleteTextCallback, Editable.EditableImpl, Editable.EditableInterface, Editable.InsertTextCallback
-
Field Summary
Fields inherited from class io.github.jwharm.javagi.base.ProxyInstance
address
-
Constructor Summary
ConstructorsConstructorDescriptionText()
Creates a new Text.Text
(MemorySegment address) Create a Text proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected Text
asParent()
Returns this instance as if it were its parent type.static Text.Builder
<? extends Text.Builder> builder()
AText.Builder
object constructs aText
with the specified properties.void
computeCursorExtents
(long position, @Nullable Rect strong, @Nullable Rect weak) Determines the positions of the strong and weak cursors for a given character position.void
Emits the "activate" signal.void
Emits the "backspace" signal.void
Emits the "copy-clipboard" signal.void
Emits the "cut-clipboard" signal.void
emitDeleteFromCursor
(DeleteType type, int count) Emits the "delete-from-cursor" signal.void
emitInsertAtCursor
(String string) Emits the "insert-at-cursor" signal.void
Emits the "insert-emoji" signal.void
emitMoveCursor
(MovementStep step, int count, boolean extend) Emits the "move-cursor" signal.void
Emits the "paste-clipboard" signal.void
emitPreeditChanged
(String preedit) Emits the "preedit-changed" signal.void
Emits the "toggle-overwrite" signal.boolean
Returns whether pressingEnter
will activate the default widget for the window containing the widget.Gets the attribute list that was set on the text widget.Get the entry buffer object which holds the text for this widget.boolean
Returns whether Emoji completion is enabled.Gets the extra menu model of the text widget.Gets the input hints of the text widget.Gets the input purpose of the text widget.int
Retrieves the character displayed when visibility is set to false.int
Retrieves the maximum allowed length of the contents.static MemoryLayout
The memory layout of the native struct.boolean
Gets whether text is overwritten when typing.Retrieves the text that will be displayed when the text widget is empty and unfocusedboolean
Returns whether the text widget will grow and shrink with the content.getTabs()
Gets the tab stops for the text widget.short
Retrieves the length of the contents.boolean
Returns whether pasted text will be truncated to the first line.static Type
getType()
Get the GType of the Text classboolean
Retrieves whether the text is visible.boolean
Causes the text widget to have the keyboard focus.onActivate
(Text.ActivateCallback handler) Emitted when the user hits theEnter
key.onBackspace
(Text.BackspaceCallback handler) Emitted when the user asks for it.Emitted to copy the selection to the clipboard.onCutClipboard
(Text.CutClipboardCallback handler) Emitted to cut the selection to the clipboard.Emitted when the user initiates a text deletion.Emitted when the user initiates the insertion of a fixed string at the cursor.onInsertEmoji
(Text.InsertEmojiCallback handler) Emitted to present the Emoji chooser.onMoveCursor
(Text.MoveCursorCallback handler) Emitted when the user initiates a cursor movement.Emitted to paste the contents of the clipboard.Emitted when the preedit text changes.Emitted to toggle the overwrite mode.void
setActivatesDefault
(boolean activates) Sets whether pressingEnter
will activate the default widget.void
setAttributes
(@Nullable AttrList attrs) Apply attributes to the contents of the text widget.void
setBuffer
(EntryBuffer buffer) Set the entry buffer object which holds the text for this widget.void
setEnableEmojiCompletion
(boolean enableEmojiCompletion) Sets whether Emoji completion is enabled.void
setExtraMenu
(@Nullable MenuModel model) Sets a menu model to add to the context menu of the text widget.void
setInputHints
(Set<InputHints> hints) Sets hints that allow input methods to fine-tune their behaviour.void
setInputHints
(InputHints... hints) Sets hints that allow input methods to fine-tune their behaviour.void
setInputPurpose
(InputPurpose purpose) Sets the input purpose of the text widget.void
setInvisibleChar
(int ch) Sets the character to use when in “password mode”.void
setMaxLength
(int length) Sets the maximum allowed length of the contents.void
setOverwriteMode
(boolean overwrite) Sets whether the text is overwritten when typing.void
setPlaceholderText
(@Nullable String text) Sets the text to be displayed when the text widget is empty and unfocused.void
setPropagateTextWidth
(boolean propagateTextWidth) Sets whether the text widget should grow and shrink with the content.void
Sets tab stops for the text widget.void
setTruncateMultiline
(boolean truncateMultiline) Sets whether pasted text should be truncated to the first line.void
setVisibility
(boolean visible) Sets whether the contents of the text widget are visible or not.void
Unsets the invisible char.static Text
withBuffer
(EntryBuffer buffer) Creates a newGtkText
with the specified buffer.Methods inherited from class org.gnome.gtk.Widget
actionSetEnabled, activateActionIfExists, activateDefault, activateWidget, addController, addCssClass, addMnemonicLabel, addTickCallback, allocate, childFocus, computeBounds, computeExpand, computeExpand, computePoint, computeTransform, contains, createPangoContext, createPangoLayout, cssChanged, directionChanged, disposeTemplate, dragCheckThreshold, emitDestroy, emitDirectionChanged, emitHide, emitKeynavFailed, emitMap, emitMnemonicActivate, emitMoveFocus, emitQueryTooltip, emitRealize, emitShow, emitStateFlagsChanged, emitUnmap, emitUnrealize, errorBell, focus, getAllocatedBaseline, getAllocatedHeight, getAllocatedWidth, getAllocation, getAncestor, getBaseline, getCanFocus, getCanTarget, getChildVisible, getClipboard, getColor, getCssClasses, getCssName, getCursor, getDefaultDirection, getDirection, getDisplay, getFirstChild, getFocusable, getFocusChild, getFocusOnClick, getFontMap, getFontOptions, getFrameClock, getHalign, getHasTooltip, getHeight, getHexpand, getHexpandSet, getLastChild, getLayoutManager, getLimitEvents, getMapped, getMarginBottom, getMarginEnd, getMarginStart, getMarginTop, getName, getNative, getNextSibling, getOpacity, getOverflow, getPangoContext, getParent, getPreferredSize, getPrevSibling, getPrimaryClipboard, getRealized, getReceivesDefault, getRequestMode, getRoot, getScaleFactor, getSensitive, getSettings, getSize, getSizeRequest, getStateFlags, getStyleContext, getTemplateChild, getTooltipMarkup, getTooltipText, getValign, getVexpand, getVexpandSet, getVisible, getWidth, grabFocus, hasCssClass, hasDefault, hasFocus, hasVisibleFocus, hide, inDestruction, initTemplate, insertActionGroup, insertAfter, insertBefore, isAncestor, isDrawable, isFocus, isSensitive, isVisible, keynavFailed, listMnemonicLabels, map, measure, mnemonicActivate, moveFocus, observeChildren, observeControllers, onDestroy, onDirectionChanged, onHide, onKeynavFailed, onMap, onMnemonicActivate, onMoveFocus, onQueryTooltip, onRealize, onShow, onStateFlagsChanged, onUnmap, onUnrealize, pick, pick, queryTooltip, queueAllocate, queueDraw, queueResize, realize, removeController, removeCssClass, removeMnemonicLabel, removeTickCallback, root, setCanFocus, setCanTarget, setChildVisible, setCssClasses, setCursor, setCursorFromName, setDefaultDirection, setDirection, setFocusable, setFocusChild, setFocusOnClick, setFontMap, setFontOptions, setHalign, setHasTooltip, setHexpand, setHexpandSet, setLayoutManager, setLimitEvents, setMarginBottom, setMarginEnd, setMarginStart, setMarginTop, setName, setOpacity, setOverflow, setParent, setReceivesDefault, setSensitive, setSizeRequest, setStateFlags, setStateFlags, setTooltipMarkup, setTooltipText, setValign, setVexpand, setVexpandSet, setVisible, shouldLayout, show, sizeAllocate, sizeAllocate, snapshot, snapshotChild, stateFlagsChanged, systemSettingChanged, translateCoordinates, triggerTooltipQuery, unmap, unparent, unrealize, unroot, unsetStateFlags, unsetStateFlags
Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newv, notify_, notify_, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.gnome.gtk.Accessible
announce, getAccessibleParent, getAccessibleRole, getAtContext, getBounds, getFirstAccessibleChild, getNextAccessibleSibling, getPlatformState, resetProperty, resetRelation, resetState, setAccessibleParent, updateNextAccessibleSibling, updatePlatformState, updateProperty, updateRelation, updateState
Methods inherited from interface org.gnome.gtk.AccessibleText
updateCaretPosition, updateContents, updateSelectionBound
Methods inherited from interface org.gnome.gtk.Buildable
getBuildableId
Methods inherited from interface org.gnome.gtk.Editable
delegateGetAccessiblePlatformState, deleteSelection, deleteText, emitChanged, emitDeleteText, emitInsertText, finishDelegate, getAlignment, getChars, getDelegate, getEditable, getEnableUndo, getMaxWidthChars, getPosition, getSelectionBounds, getText, getWidthChars, initDelegate, insertText, onChanged, onDeleteText, onInsertText, selectRegion, setAlignment, setEditable, setEnableUndo, setMaxWidthChars, setPosition, setText, setWidthChars
-
Constructor Details
-
Text
Create a Text proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
Text
public Text()Creates a new Text.
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()
doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName()
. This will call the native function pointer of this virtual method in the typeclass of the parent type. -
withBuffer
Creates a newGtkText
with the specified buffer.- Parameters:
buffer
- the buffer to use- Returns:
- a new
GtkText
-
computeCursorExtents
public void computeCursorExtents(long position, @Nullable @Nullable Rect strong, @Nullable @Nullable Rect weak) Determines the positions of the strong and weak cursors for a given character position.The position of each cursor is stored as a zero-width rectangle. The strong cursor location is the location where characters of the directionality equal to the base direction are inserted. The weak cursor location is the location where characters of the directionality opposite to the base direction are inserted.
The rectangle positions are in widget coordinates.
- Parameters:
position
- the character positionstrong
- location to store the strong cursor positionweak
- location to store the weak cursor position- Since:
- 4.4
-
getActivatesDefault
public boolean getActivatesDefault()Returns whether pressingEnter
will activate the default widget for the window containing the widget.- Returns:
- true if this Text will activate the default widget
-
getAttributes
Gets the attribute list that was set on the text widget.- Returns:
- the attribute list
-
getBuffer
Get the entry buffer object which holds the text for this widget.- Returns:
- the entry buffer object
-
getEnableEmojiCompletion
public boolean getEnableEmojiCompletion()Returns whether Emoji completion is enabled.- Returns:
- true if Emoji completion is enabled
-
getExtraMenu
Gets the extra menu model of the text widget.- Returns:
- the menu model
-
getInputHints
Gets the input hints of the text widget.- Returns:
- the input hints
-
getInputPurpose
Gets the input purpose of the text widget.- Returns:
- the input purpose
-
getInvisibleChar
public int getInvisibleChar()Retrieves the character displayed when visibility is set to false.Note that GTK does not compute this value unless it needs it, so the value returned by this function is not very useful unless it has been explicitly set with
setInvisibleChar(int)
.- Returns:
- the current invisible char, or 0, if
text
does not show invisible text at all
-
getMaxLength
public int getMaxLength()Retrieves the maximum allowed length of the contents.See
setMaxLength(int)
.This is equivalent to getting this Text's
GtkEntryBuffer
and callingEntryBuffer.getMaxLength()
on it.- Returns:
- the maximum allowed number of characters, or 0 if there is no limit
-
getOverwriteMode
public boolean getOverwriteMode()Gets whether text is overwritten when typing.- Returns:
- whether text is overwritten when typing
-
getPlaceholderText
Retrieves the text that will be displayed when the text widget is empty and unfocused- Returns:
- the placeholder text
-
getPropagateTextWidth
public boolean getPropagateTextWidth()Returns whether the text widget will grow and shrink with the content.- Returns:
- true if this Text will propagate the text width
-
getTabs
Gets the tab stops for the text widget.- Returns:
- the tab stops
-
getTextLength
public short getTextLength()Retrieves the length of the contents.This is equivalent to getting this Text's
GtkEntryBuffer
and callingEntryBuffer.getLength()
on it.- Returns:
- the length of the contents, in characters
-
getTruncateMultiline
public boolean getTruncateMultiline()Returns whether pasted text will be truncated to the first line.- Returns:
- true if this Text will truncate pasted multi-line text
-
getVisibility
public boolean getVisibility()Retrieves whether the text is visible.- Returns:
- true if the text is visible
-
grabFocusWithoutSelecting
public boolean grabFocusWithoutSelecting()Causes the text widget to have the keyboard focus.It behaves like
Widget.grabFocus()
, except that it does not select the contents of this Text.You only want to call this on some special entries which the user usually doesn't want to replace all text in, such as search-as-you-type entries.
- Returns:
- true if focus is now inside this Text
-
setActivatesDefault
public void setActivatesDefault(boolean activates) Sets whether pressingEnter
will activate the default widget.This usually means that the dialog containing this Text will be closed, since the default widget is usually one of the dialog buttons.
- Parameters:
activates
- true to activate window’s default widget onEnter
keypress
-
setAttributes
Apply attributes to the contents of the text widget.- Parameters:
attrs
- a list of style attributes
-
setBuffer
Set the entry buffer object which holds the text for this widget.- Parameters:
buffer
- an entry buffer object
-
setEnableEmojiCompletion
public void setEnableEmojiCompletion(boolean enableEmojiCompletion) Sets whether Emoji completion is enabled.If it is, typing ':', followed by a recognized keyword, will pop up a window with suggested Emojis matching the keyword.
- Parameters:
enableEmojiCompletion
- true to enable Emoji completion
-
setExtraMenu
Sets a menu model to add to the context menu of the text widget.- Parameters:
model
- a menu model
-
setInputHints
Sets hints that allow input methods to fine-tune their behaviour.- Parameters:
hints
- input hints
-
setInputHints
Sets hints that allow input methods to fine-tune their behaviour.- Parameters:
hints
- input hints
-
setInputPurpose
Sets the input purpose of the text widget.The input purpose can be used by on-screen keyboards and other input methods to adjust their behaviour.
- Parameters:
purpose
- the input purpose
-
setInvisibleChar
public void setInvisibleChar(int ch) Sets the character to use when in “password mode”.By default, GTK picks the best invisible char available in the current font. If you set the invisible char to 0, then the user will get no feedback at all; there will be no text on the screen as they type.
- Parameters:
ch
- a Unicode character
-
setMaxLength
public void setMaxLength(int length) Sets the maximum allowed length of the contents.If the current contents are longer than the given length, they will be truncated to fit.
This is equivalent to getting this Text's
GtkEntryBuffer
and callingEntryBuffer.setMaxLength(int)
on it.- Parameters:
length
- the maximum length of the text, or 0 for no maximum. (other than the maximum length of entries.) The value passed in will be clamped to the range 0-65536
-
setOverwriteMode
public void setOverwriteMode(boolean overwrite) Sets whether the text is overwritten when typing.- Parameters:
overwrite
- new value
-
setPlaceholderText
Sets the text to be displayed when the text widget is empty and unfocused.This can be used to give a visual hint of the expected contents of the text widget.
- Parameters:
text
- a string to be displayed when this Text is empty and unfocused
-
setPropagateTextWidth
public void setPropagateTextWidth(boolean propagateTextWidth) Sets whether the text widget should grow and shrink with the content.- Parameters:
propagateTextWidth
- true to propagate the text width
-
setTabs
Sets tab stops for the text widget.- Parameters:
tabs
- tab stops
-
setTruncateMultiline
public void setTruncateMultiline(boolean truncateMultiline) Sets whether pasted text should be truncated to the first line.- Parameters:
truncateMultiline
- true to truncate multi-line text
-
setVisibility
public void setVisibility(boolean visible) Sets whether the contents of the text widget are visible or not.When visibility is set to false, characters are displayed as the invisible char, and it will also appear that way when the text in the widget is copied to the clipboard.
By default, GTK picks the best invisible character available in the current font, but it can be changed with
setInvisibleChar(int)
.Note that you probably want to set
Gtk.Text:input-purpose
toGtk.InputPurpose.password
orGtk.InputPurpose.pin
to inform input methods about the purpose of this widget, in addition to setting visibility to false.- Parameters:
visible
- true if the contents of the text widget are displayed as plain text
-
unsetInvisibleChar
public void unsetInvisibleChar()Unsets the invisible char.After calling this, the default invisible char is used again.
-
onActivate
Emitted when the user hits theEnter
key.The default bindings for this signal are all forms of the
Enter
key.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitActivate
public void emitActivate()Emits the "activate" signal. SeeonActivate(org.gnome.gtk.Text.ActivateCallback)
. -
onBackspace
Emitted when the user asks for it.This is a keybinding signal.
The default bindings for this signal are
Backspace
andShift
+Backspace
.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitBackspace
public void emitBackspace()Emits the "backspace" signal. SeeonBackspace(org.gnome.gtk.Text.BackspaceCallback)
. -
onCopyClipboard
public SignalConnection<Text.CopyClipboardCallback> onCopyClipboard(Text.CopyClipboardCallback handler) Emitted to copy the selection to the clipboard.This is a keybinding signal.
The default bindings for this signal are
Ctrl
+c
andCtrl
+Insert
.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitCopyClipboard
public void emitCopyClipboard()Emits the "copy-clipboard" signal. SeeonCopyClipboard(org.gnome.gtk.Text.CopyClipboardCallback)
. -
onCutClipboard
public SignalConnection<Text.CutClipboardCallback> onCutClipboard(Text.CutClipboardCallback handler) Emitted to cut the selection to the clipboard.This is a keybinding signal.
The default bindings for this signal are
Ctrl
+x
andShift
+Delete
.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitCutClipboard
public void emitCutClipboard()Emits the "cut-clipboard" signal. SeeonCutClipboard(org.gnome.gtk.Text.CutClipboardCallback)
. -
onDeleteFromCursor
public SignalConnection<Text.DeleteFromCursorCallback> onDeleteFromCursor(Text.DeleteFromCursorCallback handler) Emitted when the user initiates a text deletion.This is a keybinding signal.
If the
type
isGtk.DeleteType.chars
, GTK deletes the selection if there is one, otherwise it deletes the requested number of characters.The default bindings for this signal are
Delete
for deleting a character andCtrl
+Delete
for deleting a word.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitDeleteFromCursor
Emits the "delete-from-cursor" signal. SeeonDeleteFromCursor(org.gnome.gtk.Text.DeleteFromCursorCallback)
. -
onInsertAtCursor
public SignalConnection<Text.InsertAtCursorCallback> onInsertAtCursor(Text.InsertAtCursorCallback handler) Emitted when the user initiates the insertion of a fixed string at the cursor.This is a keybinding signal.
This signal has no default bindings.
- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitInsertAtCursor
Emits the "insert-at-cursor" signal. SeeonInsertAtCursor(org.gnome.gtk.Text.InsertAtCursorCallback)
. -
onInsertEmoji
Emitted to present the Emoji chooser.This is a keybinding signal.
The default bindings for this signal are
Ctrl
+.
andCtrl
+;
- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitInsertEmoji
public void emitInsertEmoji()Emits the "insert-emoji" signal. SeeonInsertEmoji(org.gnome.gtk.Text.InsertEmojiCallback)
. -
onMoveCursor
Emitted when the user initiates a cursor movement.If the cursor is not visible in
self
, this signal causes the viewport to be moved instead.This is a keybinding signal.
Applications should not connect to it, but may emit it with
GObjects.signalEmitByName(org.gnome.gobject.GObject, java.lang.String, java.lang.Object...)
if they need to control the cursor programmatically.The default bindings for this signal come in two variants, the variant with the
Shift
modifier extends the selection, the variant without it does not. There are too many key combinations to list them all here.←
,→
,↑
,↓
move by individual characters/linesCtrl
+←
, etc. move by words/paragraphsHome
andEnd
move to the ends of the buffer
- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitMoveCursor
Emits the "move-cursor" signal. SeeonMoveCursor(org.gnome.gtk.Text.MoveCursorCallback)
. -
onPasteClipboard
public SignalConnection<Text.PasteClipboardCallback> onPasteClipboard(Text.PasteClipboardCallback handler) Emitted to paste the contents of the clipboard.This is a keybinding signal.
The default bindings for this signal are
Ctrl
+v
andShift
+Insert
.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitPasteClipboard
public void emitPasteClipboard()Emits the "paste-clipboard" signal. SeeonPasteClipboard(org.gnome.gtk.Text.PasteClipboardCallback)
. -
onPreeditChanged
public SignalConnection<Text.PreeditChangedCallback> onPreeditChanged(Text.PreeditChangedCallback handler) Emitted when the preedit text changes.If an input method is used, the typed text will not immediately be committed to the buffer. So if you are interested in the text, connect to this signal.
- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitPreeditChanged
Emits the "preedit-changed" signal. SeeonPreeditChanged(org.gnome.gtk.Text.PreeditChangedCallback)
. -
onToggleOverwrite
public SignalConnection<Text.ToggleOverwriteCallback> onToggleOverwrite(Text.ToggleOverwriteCallback handler) Emitted to toggle the overwrite mode.This is a keybinding signal.
The default bindings for this signal is
Insert
.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitToggleOverwrite
public void emitToggleOverwrite()Emits the "toggle-overwrite" signal. SeeonToggleOverwrite(org.gnome.gtk.Text.ToggleOverwriteCallback)
. -
builder
AText.Builder
object constructs aText
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withText.Builder.build()
.
-