Package ch.bailu.gtk.gtk
Klasse ComboBox
- Alle implementierten Schnittstellen:
PointerInterface
- Bekannte direkte Unterklassen:
ComboBoxText
A `GtkComboBox` is a widget that allows the user to choose from a list of
valid choices.
<picture>
<source srcset="combo-box-dark.png" media="(prefers-color-scheme: dark)">
<img alt="An example GtkComboBox" src="combo-box.png">
</picture>
The `GtkComboBox` displays the selected choice; when activated, the
`GtkComboBox` displays a popup which allows the user to make a new choice.
The `GtkComboBox` uses the model-view pattern; the list of valid choices
is specified in the form of a tree model, and the display of the choices
can be adapted to the data in the model by using cell renderers, as you
would in a tree view. This is possible since `GtkComboBox` implements the
[iface@Gtk.CellLayout] interface. The tree model holding the valid
choices is not restricted to a flat list, it can be a real tree, and the
popup will reflect the tree structure.
To allow the user to enter values not in the model, the
[property@Gtk.ComboBox:has-entry] property allows the `GtkComboBox` to
contain a [class@Gtk.Entry]. This entry can be accessed by calling
[method@Gtk.ComboBox.get_child] on the combo box.
For a simple list of textual choices, the model-view API of `GtkComboBox`
can be a bit overwhelming. In this case, [class@Gtk.ComboBoxText] offers
a simple alternative. Both `GtkComboBox` and `GtkComboBoxText` can contain
an entry.
## CSS nodes
```
combobox
├── box.linked
│ ╰── button.combo
│ ╰── box
│ ├── cellview
│ ╰── arrow
╰── window.popup
```
A normal combobox contains a box with the .linked class, a button
with the .combo class and inside those buttons, there are a cellview and
an arrow.
```
combobox
├── box.linked
│ ├── entry.combo
│ ╰── button.combo
│ ╰── box
│ ╰── arrow
╰── window.popup
```
A `GtkComboBox` with an entry has a single CSS node with name combobox.
It contains a box with the .linked class. That box contains an entry and
a button, both with the .combo class added. The button also contains another
node with name arrow.
## Accessibility
`GtkComboBox` uses the [enum@Gtk.AccessibleRole.combo_box] role.
valid choices.
<picture>
<source srcset="combo-box-dark.png" media="(prefers-color-scheme: dark)">
<img alt="An example GtkComboBox" src="combo-box.png">
</picture>
The `GtkComboBox` displays the selected choice; when activated, the
`GtkComboBox` displays a popup which allows the user to make a new choice.
The `GtkComboBox` uses the model-view pattern; the list of valid choices
is specified in the form of a tree model, and the display of the choices
can be adapted to the data in the model by using cell renderers, as you
would in a tree view. This is possible since `GtkComboBox` implements the
[iface@Gtk.CellLayout] interface. The tree model holding the valid
choices is not restricted to a flat list, it can be a real tree, and the
popup will reflect the tree structure.
To allow the user to enter values not in the model, the
[property@Gtk.ComboBox:has-entry] property allows the `GtkComboBox` to
contain a [class@Gtk.Entry]. This entry can be accessed by calling
[method@Gtk.ComboBox.get_child] on the combo box.
For a simple list of textual choices, the model-view API of `GtkComboBox`
can be a bit overwhelming. In this case, [class@Gtk.ComboBoxText] offers
a simple alternative. Both `GtkComboBox` and `GtkComboBoxText` can contain
an entry.
## CSS nodes
```
combobox
├── box.linked
│ ╰── button.combo
│ ╰── box
│ ├── cellview
│ ╰── arrow
╰── window.popup
```
A normal combobox contains a box with the .linked class, a button
with the .combo class and inside those buttons, there are a cellview and
an arrow.
```
combobox
├── box.linked
│ ├── entry.combo
│ ╰── button.combo
│ ╰── box
│ ╰── arrow
╰── window.popup
```
A `GtkComboBox` with an entry has a single CSS node with name combobox.
It contains a box with the .linked class. That box contains an entry and
a button, both with the .combo class added. The button also contains another
node with name arrow.
## Accessibility
`GtkComboBox` uses the [enum@Gtk.AccessibleRole.combo_box] role.
-
Verschachtelte Klassen - Übersicht
Verschachtelte KlassenModifizierer und TypKlasseBeschreibungstatic interface
static interface
static interface
static interface
static interface
static interface
static interface
static interface
Von Klasse geerbte verschachtelte Klassen/Schnittstellen ch.bailu.gtk.gtk.Widget
Widget.OnDestroy, Widget.OnDirectionChanged, Widget.OnHide, Widget.OnKeynavFailed, Widget.OnMap, Widget.OnMnemonicActivate, Widget.OnMoveFocus, Widget.OnQueryTooltip, Widget.OnRealize, Widget.OnShow, Widget.OnStateFlagsChanged, Widget.OnTickCallback, Widget.OnUnmap, Widget.OnUnrealize
Von Klasse geerbte verschachtelte Klassen/Schnittstellen ch.bailu.gtk.gobject.Object
Object.OnBindingTransformFunc, Object.OnDuplicateFunc, Object.OnNotify, Object.OnToggleNotify, Object.OnWeakNotify
-
Feldübersicht
FelderModifizierer und TypFeldBeschreibungstatic final String
static final String
static final String
static final String
static final String
static final String
Von Klasse geerbte Felder ch.bailu.gtk.gtk.Widget
SIGNAL_ON_DESTROY, SIGNAL_ON_DIRECTION_CHANGED, SIGNAL_ON_HIDE, SIGNAL_ON_KEYNAV_FAILED, SIGNAL_ON_MAP, SIGNAL_ON_MNEMONIC_ACTIVATE, SIGNAL_ON_MOVE_FOCUS, SIGNAL_ON_QUERY_TOOLTIP, SIGNAL_ON_REALIZE, SIGNAL_ON_SHOW, SIGNAL_ON_STATE_FLAGS_CHANGED, SIGNAL_ON_UNMAP, SIGNAL_ON_UNREALIZE
Von Klasse geerbte Felder ch.bailu.gtk.gobject.Object
SIGNAL_ON_NOTIFY
-
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungImplements interfaceAccessible
.Implements interfaceBuildable
.Implements interfaceCellEditable
.Implements interfaceCellLayout
.Implements interfaceConstraintTarget
.int
Veraltet.Veraltet.boolean
getActiveIter
(TreeIter iter) Veraltet.int
Veraltet.getChild()
Veraltet.static ClassHandler
int
Veraltet.boolean
Veraltet.int
Veraltet.static int
getModel()
Veraltet.static long
static TypeSystem.TypeSize
boolean
Veraltet.static long
static TypeSystem.TypeSize
static ComboBox
Veraltet.static ComboBox
Veraltet.static ComboBox
newWithModelComboBox
(TreeModel model) Veraltet.onActivate
(ComboBox.OnActivate signal) Connect to signal "activate".onChanged
(ComboBox.OnChanged signal) Connect to signal "changed".Connect to signal "format-entry-text".onMoveActive
(ComboBox.OnMoveActive signal) Connect to signal "move-active".onPopdown
(ComboBox.OnPopdown signal) Connect to signal "popdown".onPopup
(ComboBox.OnPopup signal) Connect to signal "popup".void
popdown()
Veraltet.void
popup()
Veraltet.void
popupForDevice
(Device device) Veraltet.void
setActive
(int index_) Veraltet.boolean
setActiveId
(Str active_id) Veraltet.boolean
setActiveId
(String active_id) Veraltet.void
setActiveIter
(TreeIter iter) Veraltet.void
setButtonSensitivity
(int sensitivity) Veraltet.void
Veraltet.void
setEntryTextColumn
(int text_column) Veraltet.void
setIdColumn
(int id_column) Veraltet.void
Veraltet.void
setPopupFixedWidth
(boolean fixed) Veraltet.void
setRowSeparatorFunc
(ComboBox.OnTreeViewRowSeparatorFunc func, Pointer data, ComboBox.OnDestroyNotify destroy) Veraltet.Von Klasse geerbte Methoden ch.bailu.gtk.gtk.Widget
actionSetEnabled, actionSetEnabled, activate, activateAction, activateAction, activateActionVariant, activateActionVariant, activateDefault, addController, addCssClass, addCssClass, addMnemonicLabel, addTickCallback, allocate, childFocus, computeBounds, computeExpand, computePoint, computeTransform, contains, createPangoContext, createPangoLayout, createPangoLayout, disposeTemplate, dragCheckThreshold, errorBell, 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, getTemplateChild, getTooltipMarkup, getTooltipText, getValign, getVexpand, getVexpandSet, getVisible, getWidth, grabFocus, hasCssClass, hasCssClass, hasDefault, hasFocus, hasVisibleFocus, hide, inDestruction, initTemplate, insertActionGroup, insertActionGroup, insertAfter, insertBefore, isAncestor, isDrawable, isFocus, isSensitive, isVisible, keynavFailed, listMnemonicLabels, map, measure, mnemonicActivate, observeChildren, observeControllers, onDestroy, onDirectionChanged, onHide, onKeynavFailed, onMap, onMnemonicActivate, onMoveFocus, onQueryTooltip, onRealize, onShow, onStateFlagsChanged, onUnmap, onUnrealize, pick, queueAllocate, queueDraw, queueResize, realize, removeController, removeCssClass, removeCssClass, removeMnemonicLabel, removeTickCallback, setCanFocus, setCanTarget, setChildVisible, setCssClasses, setCursor, setCursorFromName, setCursorFromName, setDefaultDirection, setDirection, setFocusable, setFocusChild, setFocusOnClick, setFontMap, setFontOptions, setHalign, setHasTooltip, setHexpand, setHexpandSet, setLayoutManager, setLimitEvents, setMarginBottom, setMarginEnd, setMarginStart, setMarginTop, setName, setName, setOpacity, setOverflow, setParent, setReceivesDefault, setSensitive, setSizeRequest, setStateFlags, setTooltipMarkup, setTooltipMarkup, setTooltipText, setTooltipText, setValign, setVexpand, setVexpandSet, setVisible, shouldLayout, show, sizeAllocate, snapshotChild, triggerTooltipQuery, unmap, unparent, unrealize, unsetStateFlags
Von Klasse geerbte Methoden ch.bailu.gtk.type.PropertyHolder
getBooleanProperty, getIntProperty, getObjectProperty, getStringProperty, getStrProperty, setBooleanProperty, setIntProperty, setObjectProperty, setStringProperty, setStrProperty
Von Klasse geerbte Methoden ch.bailu.gtk.gobject.Object
addToggleRef, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, disconnect, disconnect, dupData, dupData, dupQdata, forceFloating, freezeNotify, get, get, getData, getData, getProperty, getProperty, getQdata, interfaceFindProperty, interfaceInstallProperty, isFloating, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, replaceData, replaceData, replaceQdata, runDispose, set, set, setData, setData, setDataFull, setDataFull, setProperty, setProperty, setQdata, setQdataFull, stealData, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref
Von Klasse geerbte Methoden ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Von Klasse geerbte Methoden ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Von Klasse geerbte Methoden java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Von Schnittstelle geerbte Methoden ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Felddetails
-
SIGNAL_ON_ACTIVATE
- Siehe auch:
-
SIGNAL_ON_CHANGED
- Siehe auch:
-
SIGNAL_ON_FORMAT_ENTRY_TEXT
- Siehe auch:
-
SIGNAL_ON_MOVE_ACTIVE
- Siehe auch:
-
SIGNAL_ON_POPDOWN
- Siehe auch:
-
SIGNAL_ON_POPUP
- Siehe auch:
-
-
Konstruktordetails
-
ComboBox
-
ComboBox
Veraltet.Creates a new empty `GtkComboBox`.
-
-
Methodendetails
-
getClassHandler
-
newWithEntryComboBox
Veraltet.Creates a new empty `GtkComboBox` with an entry.
In order to use a combo box with entry, you need to tell it
which column of the model contains the text for the entry
by calling [method@Gtk.ComboBox.set_entry_text_column].- Gibt zurück:
- A new `GtkComboBox`
-
newWithModelComboBox
Veraltet.Creates a new `GtkComboBox` with a model.- Parameter:
model
- a `GtkTreeModel`- Gibt zurück:
- A new `GtkComboBox`
-
newWithModelAndEntryComboBox
Veraltet.Creates a new empty `GtkComboBox` with an entry and a model.
See also [ctor@Gtk.ComboBox.new_with_entry].- Parameter:
model
- A `GtkTreeModel`- Gibt zurück:
- A new `GtkComboBox`
-
getActive
Veraltet.Returns the index of the currently active item.
If the model is a non-flat treemodel, and the active item is not
an immediate child of the root of the tree, this function returns
`gtk_tree_path_get_indices (path)[0]`, where `path` is the
[struct@Gtk.TreePath] of the active item.- Gibt zurück:
- An integer which is the index of the currently active item, or -1 if there’s no active item
-
getActiveId
Veraltet.Returns the ID of the active row of @combo_box.
This value is taken from the active row and the column specified
by the [property@Gtk.ComboBox:id-column] property of @combo_box
(see [method@Gtk.ComboBox.set_id_column]).
The returned value is an interned string which means that you can
compare the pointer by value to other interned strings and that you
must not free it.
If the [property@Gtk.ComboBox:id-column] property of @combo_box is
not set, or if no row is active, or if the active row has a %NULL
ID value, then %NULL is returned.- Gibt zurück:
- the ID of the active row
-
getActiveIter
Veraltet.Sets @iter to point to the currently active item.
If no item is active, @iter is left unchanged.- Parameter:
iter
- A `GtkTreeIter`- Gibt zurück:
- %TRUE if @iter was set, %FALSE otherwise
-
getButtonSensitivity
Veraltet.Returns whether the combo box sets the dropdown button
sensitive or not when there are no items in the model.- Gibt zurück:
- %GTK_SENSITIVITY_ON if the dropdown button is sensitive when the model is empty, %GTK_SENSITIVITY_OFF if the button is always insensitive or %GTK_SENSITIVITY_AUTO if it is only sensitive as long as the model has one item to be selected.
-
getChild
Veraltet.Gets the child widget of @combo_box.- Gibt zurück:
- the child widget of @combo_box
-
getEntryTextColumn
Veraltet.Returns the column which @combo_box is using to get the strings
from to display in the internal entry.- Gibt zurück:
- A column in the data source model of @combo_box.
-
getHasEntry
Veraltet.Returns whether the combo box has an entry.- Gibt zurück:
- whether there is an entry in @combo_box.
-
getIdColumn
Veraltet.Returns the column which @combo_box is using to get string IDs
for values from.- Gibt zurück:
- A column in the data source model of @combo_box.
-
getModel
Veraltet.Returns the `GtkTreeModel` of @combo_box.- Gibt zurück:
- A `GtkTreeModel` which was passed during construction.
-
getPopupFixedWidth
Veraltet.Gets whether the popup uses a fixed width.- Gibt zurück:
- %TRUE if the popup uses a fixed width
-
popdown
Veraltet.Hides the menu or dropdown list of @combo_box.
This function is mostly intended for use by accessibility technologies;
applications should have little use for it. -
popup
Veraltet.Pops up the menu or dropdown list of @combo_box.
This function is mostly intended for use by accessibility technologies;
applications should have little use for it.
Before calling this, @combo_box must be mapped, or nothing will happen. -
popupForDevice
Veraltet.Pops up the menu of @combo_box.
Note that currently this does not do anything with the device, as it was
previously only used for list-mode combo boxes, and those were removed
in GTK 4. However, it is retained in case similar functionality is added
back later.- Parameter:
device
- a `GdkDevice`
-
setActive
Veraltet.Sets the active item of @combo_box to be the item at @index.- Parameter:
index_
- An index in the model passed during construction, or -1 to have no active item
-
setActiveId
Veraltet.Changes the active row of @combo_box to the one that has an ID equal to
@active_id.
If @active_id is %NULL, the active row is unset. Rows having
a %NULL ID string cannot be made active by this function.
If the [property@Gtk.ComboBox:id-column] property of @combo_box is
unset or if no row has the given ID then the function does nothing
and returns %FALSE.- Parameter:
active_id
- the ID of the row to select- Gibt zurück:
- %TRUE if a row with a matching ID was found. If a %NULL @active_id was given to unset the active row, the function always returns %TRUE.
-
setActiveId
Veraltet.Changes the active row of @combo_box to the one that has an ID equal to
@active_id.
If @active_id is %NULL, the active row is unset. Rows having
a %NULL ID string cannot be made active by this function.
If the [property@Gtk.ComboBox:id-column] property of @combo_box is
unset or if no row has the given ID then the function does nothing
and returns %FALSE.- Parameter:
active_id
- the ID of the row to select- Gibt zurück:
- %TRUE if a row with a matching ID was found. If a %NULL @active_id was given to unset the active row, the function always returns %TRUE.
-
setActiveIter
Veraltet.Sets the current active item to be the one referenced by @iter.
If @iter is %NULL, the active item is unset.- Parameter:
iter
- The `GtkTreeIter`
-
setButtonSensitivity
Veraltet.Sets whether the dropdown button of the combo box should update
its sensitivity depending on the model contents.- Parameter:
sensitivity
- specify the sensitivity of the dropdown button
-
setChild
Veraltet.Sets the child widget of @combo_box.- Parameter:
child
- the child widget
-
setEntryTextColumn
Veraltet.Sets the model column which @combo_box should use to get strings
from to be @text_column.
For this column no separate
[class@Gtk.CellRenderer] is needed.
The column @text_column in the model of @combo_box must be of
type %G_TYPE_STRING.
This is only relevant if @combo_box has been created with
[property@Gtk.ComboBox:has-entry] as %TRUE.- Parameter:
text_column
- A column in @model to get the strings from for the internal entry
-
setIdColumn
Veraltet.Sets the model column which @combo_box should use to get string IDs
for values from.
The column @id_column in the model of @combo_box must be of type
%G_TYPE_STRING.- Parameter:
id_column
- A column in @model to get string IDs for values from
-
setModel
Veraltet.Sets the model used by @combo_box to be @model.
Will unset a previously set model (if applicable). If model is %NULL,
then it will unset the model.
Note that this function does not clear the cell renderers, you have to
call [method@Gtk.CellLayout.clear] yourself if you need to set up different
cell renderers for the new model.- Parameter:
model
- A `GtkTreeModel`
-
setPopupFixedWidth
Veraltet.Specifies whether the popup’s width should be a fixed width.
If @fixed is %TRUE, the popup's width is set to match the
allocated width of the combo box.- Parameter:
fixed
- whether to use a fixed popup width
-
setRowSeparatorFunc
@Deprecated public void setRowSeparatorFunc(ComboBox.OnTreeViewRowSeparatorFunc func, @Nullable Pointer data, ComboBox.OnDestroyNotify destroy) Veraltet.Sets the row separator function, which is used to determine
whether a row should be drawn as a separator.
If the row separator function is %NULL, no separators are drawn.
This is the default value.- Parameter:
func
- a `GtkTreeViewRowSeparatorFunc`data
- user data to pass to @funcdestroy
- destroy notifier for @data
-
onActivate
Connect to signal "activate".
SeeComboBox.OnActivate.onActivate()
for signal description.
FieldSIGNAL_ON_ACTIVATE
contains original signal name and can be used as resource reference.- Parameter:
signal
- callback function (lambda).- Gibt zurück:
SignalHandler
. Can be used to disconnect signal and to release callback function.
-
onChanged
Connect to signal "changed".
SeeComboBox.OnChanged.onChanged()
for signal description.
FieldSIGNAL_ON_CHANGED
contains original signal name and can be used as resource reference.- Parameter:
signal
- callback function (lambda).- Gibt zurück:
SignalHandler
. Can be used to disconnect signal and to release callback function.
-
onFormatEntryText
Connect to signal "format-entry-text".
SeeComboBox.OnFormatEntryText.onFormatEntryText(ch.bailu.gtk.type.Str)
for signal description.
FieldSIGNAL_ON_FORMAT_ENTRY_TEXT
contains original signal name and can be used as resource reference.- Parameter:
signal
- callback function (lambda).- Gibt zurück:
SignalHandler
. Can be used to disconnect signal and to release callback function.
-
onMoveActive
Connect to signal "move-active".
SeeComboBox.OnMoveActive.onMoveActive(int)
for signal description.
FieldSIGNAL_ON_MOVE_ACTIVE
contains original signal name and can be used as resource reference.- Parameter:
signal
- callback function (lambda).- Gibt zurück:
SignalHandler
. Can be used to disconnect signal and to release callback function.
-
onPopdown
Connect to signal "popdown".
SeeComboBox.OnPopdown.onPopdown()
for signal description.
FieldSIGNAL_ON_POPDOWN
contains original signal name and can be used as resource reference.- Parameter:
signal
- callback function (lambda).- Gibt zurück:
SignalHandler
. Can be used to disconnect signal and to release callback function.
-
onPopup
Connect to signal "popup".
SeeComboBox.OnPopup.onPopup()
for signal description.
FieldSIGNAL_ON_POPUP
contains original signal name and can be used as resource reference.- Parameter:
signal
- callback function (lambda).- Gibt zurück:
SignalHandler
. Can be used to disconnect signal and to release callback function.
-
asAccessible
Implements interfaceAccessible
. Call this to get access to interface functions.- Setzt außer Kraft:
asAccessible
in KlasseWidget
- Gibt zurück:
Accessible
-
asBuildable
Implements interfaceBuildable
. Call this to get access to interface functions.- Setzt außer Kraft:
asBuildable
in KlasseWidget
- Gibt zurück:
Buildable
-
asCellEditable
Implements interfaceCellEditable
. Call this to get access to interface functions.- Gibt zurück:
CellEditable
-
asCellLayout
Implements interfaceCellLayout
. Call this to get access to interface functions.- Gibt zurück:
CellLayout
-
asConstraintTarget
Implements interfaceConstraintTarget
. Call this to get access to interface functions.- Setzt außer Kraft:
asConstraintTarget
in KlasseWidget
- Gibt zurück:
ConstraintTarget
-
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-