Text
open class Text : Widget, TextProtocol
The GtkText
widget is a single-line text entry widget.
GtkText
is the common implementation of single-line text editing
that is shared between GtkEntry
, GtkPasswordEntry
, GtkSpinButton
and other widgets. In all of these, GtkText
is used as the delegate
for the [ifaceGtk.Editable
] implementation.
A fairly large set of key bindings are 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 [methodGtk.Text.set_visibility
].
In this mode, entered text is displayed using a “invisible” character.
By default, GTK picks the best invisible character that is available
in the current font, but it can be changed with
[methodGtk.Text.set_invisible_char
].
If you are looking to add icons or progress display in an entry, look
at GtkEntry
. There other alternatives for more specialized use cases,
such as GtkSearchEntry
.
If you need multi-line editable text, look at GtkTextView
.
CSS nodes
text[.read-only]
├── placeholder
├── undershoot.left
├── undershoot.right
├── [selection]
├── [block-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 below text as well.
The undershoot nodes are used to draw the underflow indication when content is scrolled out of view. These nodes get the .left and .right style classes 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_ACCESSIBLE_ROLE_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.
The Text
type acts as a reference-counted owner of an underlying GtkText
instance.
It provides the methods that can operate on this data type through TextProtocol
conformance.
Use Text
as a strong reference or owner of a GtkText
instance.
-
Designated initialiser from the underlying `C` data type.
This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the
Text
instance.Declaration
Swift
@inlinable public init(_ op: UnsafeMutablePointer<GtkText>)
Parameters
op
pointer to the underlying object
-
Designated initialiser from a constant pointer to the underlying
C
data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theText
instance.Declaration
Swift
@inlinable public init(_ op: UnsafePointer<GtkText>)
Parameters
op
pointer to the underlying object
-
Optional initialiser from a non-mutating
gpointer
to the underlyingC
data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theText
instance.Declaration
Swift
@inlinable override public init!(gpointer op: gpointer?)
Parameters
op
gpointer to the underlying object
-
Optional initialiser from a non-mutating
gconstpointer
to the underlyingC
data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theText
instance.Declaration
Swift
@inlinable override public init!(gconstpointer op: gconstpointer?)
Parameters
op
pointer to the underlying object
-
Optional initialiser from a constant pointer to the underlying
C
data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theText
instance.Declaration
Swift
@inlinable public init!(_ op: UnsafePointer<GtkText>?)
Parameters
op
pointer to the underlying object
-
Optional initialiser from the underlying
C
data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theText
instance.Declaration
Swift
@inlinable public init!(_ op: UnsafeMutablePointer<GtkText>?)
Parameters
op
pointer to the underlying object
-
Designated initialiser from the underlying
C
data type. Will retainGtkText
. i.e., ownership is transferred to theText
instance.Declaration
Swift
@inlinable public init(retaining op: UnsafeMutablePointer<GtkText>)
Parameters
op
pointer to the underlying object
-
Reference intialiser for a related type that implements
TextProtocol
Will retainGtkText
.Declaration
Swift
@inlinable public init<T>(text other: T) where T : TextProtocol
Parameters
other
an instance of a related type that implements
TextProtocol
-
Unsafe typed initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
TextProtocol
.Declaration
Swift
@inlinable override public init<T>(cPointer p: UnsafeMutablePointer<T>)
Parameters
cPointer
pointer to the underlying object
-
Unsafe typed, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
TextProtocol
.Declaration
Swift
@inlinable override public init<T>(retainingCPointer cPointer: UnsafeMutablePointer<T>)
Parameters
cPointer
pointer to the underlying object
-
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
TextProtocol
.Declaration
Swift
@inlinable override public init(raw p: UnsafeRawPointer)
Parameters
p
raw pointer to the underlying object
-
Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
TextProtocol
.Declaration
Swift
@inlinable override public init(retainingRaw raw: UnsafeRawPointer)
-
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
TextProtocol
.Declaration
Swift
@inlinable public required init(raw p: UnsafeMutableRawPointer)
Parameters
p
mutable raw pointer to the underlying object
-
Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
TextProtocol
.Declaration
Swift
@inlinable required public init(retainingRaw raw: UnsafeMutableRawPointer)
Parameters
raw
mutable raw pointer to the underlying object
-
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
TextProtocol
.Declaration
Swift
@inlinable override public init(opaquePointer p: OpaquePointer)
Parameters
p
opaque pointer to the underlying object
-
Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
TextProtocol
.Declaration
Swift
@inlinable override public init(retainingOpaquePointer p: OpaquePointer)
Parameters
p
opaque pointer to the underlying object
-
Creates a new
GtkText
.Declaration
Swift
@inlinable public init()
-
Creates a new
GtkText
with the specified text buffer.Declaration
Swift
@inlinable public init<EntryBufferT>(buffer: EntryBufferT) where EntryBufferT : EntryBufferProtocol
-
Creates a new
GtkText
with the specified text buffer.Declaration
Swift
@inlinable public static func newWith<EntryBufferT>(buffer: EntryBufferT) -> Widget! where EntryBufferT : EntryBufferProtocol