class Gtk::EntryCompletion
- Gtk::EntryCompletion
- GObject::Object
- Reference
- Object
Overview
Gtk::EntryCompletion
is an auxiliary object to provide completion functionality
for Gtk::Entry
.
It implements the Gtk::CellLayout
interface, to allow the user
to add extra cells to the Gtk::TreeView
with completion matches.
“Completion functionality” means that when the user modifies the text
in the entry, Gtk::EntryCompletion
checks which rows in the model match
the current content of the entry, and displays a list of matches.
By default, the matching is done by comparing the entry text
case-insensitively against the text column of the model (see
Gtk::EntryCompletion#text_column=
), but this can be overridden
with a custom match function (see Gtk::EntryCompletion#match_func=
).
When the user selects a completion, the content of the entry is
updated. By default, the content of the entry is replaced by the
text column of the model, but this can be overridden by connecting
to the [signal@Gtk.EntryCompletion::match-selected] signal and updating the
entry in the signal handler. Note that you should return true
from
the signal handler to suppress the default behaviour.
To add completion functionality to an entry, use
Gtk::Entry#completion=
.
Gtk::EntryCompletion
uses a Gtk::TreeModelFilter
model to
represent the subset of the entire model that is currently matching.
While the Gtk::EntryCompletion
signals
[signal@Gtk.EntryCompletion::match-selected] and
[signal@Gtk.EntryCompletion::cursor-on-match] take the original model
and an iter pointing to that model as arguments, other callbacks and
signals (such as Gtk::CellLayoutDataFunc
or
[signal@Gtk.CellArea::apply-attributes)]
will generally take the filter model as argument. As long as you are
only calling Gtk::TreeModel#get
, this will make no difference to
you. If for some reason, you need the original model, use
Gtk::TreeModelFilter#model
. Don’t forget to use
Gtk::TreeModelFilter#convert_iter_to_child_iter
to obtain a
matching iter.
Included Modules
Defined in:
lib/gi-crystal/src/auto/gtk-4.0/entry_completion.crConstructors
-
.new : self
Creates a new
Gtk::EntryCompletion
object. - .new(*, cell_area : Gtk::CellArea | Nil = nil, inline_completion : Bool | Nil = nil, inline_selection : Bool | Nil = nil, minimum_key_length : Int32 | Nil = nil, model : Gtk::TreeModel | Nil = nil, popup_completion : Bool | Nil = nil, popup_set_width : Bool | Nil = nil, popup_single_match : Bool | Nil = nil, text_column : Int32 | Nil = nil)
-
.new_with_area(area : Gtk::CellArea) : self
Creates a new
Gtk::EntryCompletion
object using the specified area.
Class Method Summary
-
.g_type : UInt64
Returns the type id (GType) registered in GLib type system.
Instance Method Summary
-
#==(other : self)
Returns
true
if this reference is the same as other. - #cell_area : Gtk::CellArea | Nil
- #cell_area=(value : Gtk::CellArea | Nil) : Gtk::CellArea | Nil
-
#complete : Nil
Requests a completion operation, or in other words a refiltering of the current list with completions, using the current key.
-
#completion_prefix : String | Nil
Get the original text entered by the user that triggered the completion or
nil
if there’s no completion ongoing. -
#compute_prefix(key : String) : String | Nil
Computes the common prefix that is shared by all rows in completion that start with key.
- #cursor_on_match_signal
-
#entry : Gtk::Widget
Gets the entry completion has been attached to.
-
#hash(hasher)
See
Object#hash(hasher)
-
#inline_completion : Bool
Returns whether the common prefix of the possible completions should be automatically inserted in the entry.
-
#inline_completion=(inline_completion : Bool) : Nil
Sets whether the common prefix of the possible completions should be automatically inserted in the entry.
- #inline_completion? : Bool
-
#inline_selection : Bool
Returns
true
if inline-selection mode is turned on. -
#inline_selection=(inline_selection : Bool) : Nil
Sets whether it is possible to cycle through the possible completions inside the entry.
- #inline_selection? : Bool
-
#insert_prefix : Nil
Requests a prefix insertion.
- #insert_prefix_signal
-
#match_func=(func : Gtk::EntryCompletionMatchFunc) : Nil
Sets the match function for completion to be func.
- #match_selected_signal
-
#minimum_key_length : Int32
Returns the minimum key length as set for completion.
-
#minimum_key_length=(length : Int32) : Nil
Requires the length of the search key for completion to be at least length.
-
#model : Gtk::TreeModel | Nil
Returns the model the
Gtk::EntryCompletion
is using as data source. -
#model=(model : Gtk::TreeModel | Nil) : Nil
Sets the model for a
Gtk::EntryCompletion
. - #no_matches_signal
-
#popup_completion : Bool
Returns whether the completions should be presented in a popup window.
-
#popup_completion=(popup_completion : Bool) : Nil
Sets whether the completions should be presented in a popup window.
- #popup_completion? : Bool
-
#popup_set_width : Bool
Returns whether the completion popup window will be resized to the width of the entry.
-
#popup_set_width=(popup_set_width : Bool) : Nil
Sets whether the completion popup window will be resized to be the same width as the entry.
- #popup_set_width? : Bool
-
#popup_single_match : Bool
Returns whether the completion popup window will appear even if there is only a single match.
-
#popup_single_match=(popup_single_match : Bool) : Nil
Sets whether the completion popup window will appear even if there is only a single match.
- #popup_single_match? : Bool
-
#text_column : Int32
Returns the column in the model of completion to get strings from.
-
#text_column=(column : Int32) : Nil
Convenience function for setting up the most used case of this code: a completion list with just strings.
Instance methods inherited from module Gtk::CellLayout
add_attribute(cell : Gtk::CellRenderer, attribute : String, column : Int32) : Nil
add_attribute,
area : Gtk::CellArea | Nil
area,
cells : GLib::List
cells,
clear : Nil
clear,
clear_attributes(cell : Gtk::CellRenderer) : Nil
clear_attributes,
pack_end(cell : Gtk::CellRenderer, expand : Bool) : Nil
pack_end,
pack_start(cell : Gtk::CellRenderer, expand : Bool) : Nil
pack_start,
reorder(cell : Gtk::CellRenderer, position : Int32) : Nil
reorder,
set_cell_data_func(cell : Gtk::CellRenderer, func : Gtk::CellLayoutDataFunc | Nil) : Nil
set_cell_data_func,
to_unsafe
to_unsafe
Constructor methods inherited from module Gtk::CellLayout
cast(obj : GObject::Object) : self
cast
Class methods inherited from module Gtk::CellLayout
cast?(obj : GObject::Object) : self | Nil
cast?,
g_type : UInt64
g_type
Instance methods inherited from module Gtk::Buildable
buildable_id : String | Nil
buildable_id,
to_unsafe
to_unsafe
Constructor methods inherited from module Gtk::Buildable
cast(obj : GObject::Object) : self
cast
Class methods inherited from module Gtk::Buildable
cast?(obj : GObject::Object) : self | Nil
cast?,
g_type : UInt64
g_type
Instance methods inherited from class GObject::Object
==(other : self)
==,
bind_property(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags) : GObject::Binding
bind_property,
bind_property_full(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags, transform_to : GObject::Closure, transform_from : GObject::Closure) : GObject::Binding
bind_property_full,
data(key : String) : Pointer(Void) | Nil
data,
finalize
finalize,
freeze_notify : Nil
freeze_notify,
getv(names : Enumerable(String), values : Enumerable(_)) : Nil
getv,
hash(hasher)
hash,
notify(property_name : String) : Nil
notify,
notify_by_pspec(pspec : GObject::ParamSpec) : Nil
notify_by_pspec,
notify_signal
notify_signal,
property(property_name : String, value : _) : Nil
property,
qdata(quark : UInt32) : Pointer(Void) | Nil
qdata,
ref_count : UInt32
ref_count,
run_dispose : Nil
run_dispose,
set_data(key : String, data : Pointer(Void) | Nil) : Nil
set_data,
set_property(property_name : String, value : _) : Nil
set_property,
steal_data(key : String) : Pointer(Void) | Nil
steal_data,
steal_qdata(quark : UInt32) : Pointer(Void) | Nil
steal_qdata,
thaw_notify : Nil
thaw_notify,
to_unsafe : Pointer(Void)
to_unsafe,
watch_closure(closure : GObject::Closure) : Nil
watch_closure
Constructor methods inherited from class GObject::Object
cast(obj : GObject::Object) : self
cast,
new(pointer : Pointer(Void), transfer : GICrystal::Transfer)new new, newv(object_type : UInt64, parameters : Enumerable(GObject::Parameter)) : self newv
Class methods inherited from class GObject::Object
cast?(obj : GObject::Object) : self | Nil
cast?,
compat_control(what : UInt64, data : Pointer(Void) | Nil) : UInt64
compat_control,
g_type : UInt64
g_type,
interface_find_property(g_iface : GObject::TypeInterface, property_name : String) : GObject::ParamSpec
interface_find_property,
interface_list_properties(g_iface : GObject::TypeInterface) : Enumerable(GObject::ParamSpec)
interface_list_properties
Macros inherited from class GObject::Object
previous_vfunc(*args)
previous_vfunc,
previous_vfunc!(*args)
previous_vfunc!,
signal(signature)
signal
Constructor Detail
Creates a new Gtk::EntryCompletion
object using the
specified area.
The Gtk::CellArea
is used to layout cells in the underlying
Gtk::TreeViewColumn
for the drop-down menu.
Class Method Detail
Returns the type id (GType) registered in GLib type system.
Instance Method Detail
Returns true
if this reference is the same as other. Invokes same?
.
Requests a completion operation, or in other words a refiltering of the current list with completions, using the current key.
The completion list view will be updated accordingly.
Get the original text entered by the user that triggered
the completion or nil
if there’s no completion ongoing.
Computes the common prefix that is shared by all rows in completion that start with key.
If no row matches key, nil
will be returned.
Note that a text column must have been set for this function to work,
see Gtk::EntryCompletion#text_column=
for details.
Returns whether the common prefix of the possible completions should be automatically inserted in the entry.
Sets whether the common prefix of the possible completions should be automatically inserted in the entry.
Sets whether it is possible to cycle through the possible completions inside the entry.
Sets the match function for completion to be func.
The match function is used to determine if a row should or should not be in the completion list.
Returns the minimum key length as set for completion.
Requires the length of the search key for completion to be at least length.
This is useful for long lists, where completing using a small key takes a lot of time and will come up with meaningless results anyway (ie, a too large dataset).
Returns the model the Gtk::EntryCompletion
is using as data source.
Returns nil
if the model is unset.
Sets the model for a Gtk::EntryCompletion
.
If completion already has a model set, it will remove it
before setting the new model. If model is nil
, then it
will unset the model.
Returns whether the completions should be presented in a popup window.
Sets whether the completions should be presented in a popup window.
Returns whether the completion popup window will be resized to the width of the entry.
Sets whether the completion popup window will be resized to be the same width as the entry.
Returns whether the completion popup window will appear even if there is only a single match.
Sets whether the completion popup window will appear even if there is only a single match.
You may want to set this to false
if you
are using [property@Gtk.EntryCompletion:inline-completion].
Returns the column in the model of completion to get strings from.
Convenience function for setting up the most used case of this code: a completion list with just strings.
This function will set up completion to have a list displaying all (and just) strings in the completion list, and to get those strings from column in the model of completion.
This functions creates and adds a Gtk::CellRendererText
for the selected
column. If you need to set the text column, but don't want the cell
renderer, use g_object_set() to set the
[property@Gtk.EntryCompletion:text-column] property directly.