Class ComboBoxText
- All Implemented Interfaces:
Accessible, Buildable, CellEditable, CellLayout, ConstraintTarget, Proxy
A GtkComboBoxText is a simple variant of GtkComboBox for text-only
use cases.
GtkComboBoxText hides the model-view complexity of GtkComboBox.
To create a GtkComboBoxText, use ComboBoxText() or
withEntry().
You can add items to a GtkComboBoxText with
appendText(String),
insertText(int, String) or
prependText(String) and remove options with
remove(int).
If the GtkComboBoxText contains an entry (via the
Gtk.ComboBox:has-entry property), its contents can be retrieved
using getActiveText().
You should not call ComboBox.setModel(TreeModel) or attempt to pack more
cells into this combo box via its CellLayout interface.
GtkComboBoxText as GtkBuildable
The GtkComboBoxText implementation of the GtkBuildable interface supports
adding items directly using the <items> element and specifying <item>
elements for each item. Each <item> element can specify the “id”
corresponding to the appended text and also supports the regular
translation attributes “translatable”, “context” and “comments”.
Here is a UI definition fragment specifying GtkComboBoxText items:
<object class="GtkComboBoxText">
<items>
<item translatable="yes" id="factory">Factory</item>
<item translatable="yes" id="home">Home</item>
<item translatable="yes" id="subway">Subway</item>
</items>
</object>
CSS nodes
combobox
╰── box.linked
├── entry.combo
├── button.combo
╰── window.popup
GtkComboBoxText has a single CSS node with name combobox. It adds
the style class .combo to the main CSS nodes of its entry and button
children, and the .linked class to the node of its internal box.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classComboBoxText.Builder<B extends ComboBoxText.Builder<B>>Deprecated.Inner class implementing a builder pattern to construct a GObject with properties.Nested classes/interfaces inherited from class ComboBox
ComboBox.ActivateCallback, ComboBox.ChangedCallback, ComboBox.ComboBoxClass, ComboBox.FormatEntryTextCallback, ComboBox.MoveActiveCallback, ComboBox.PopdownCallback, ComboBox.PopupCallbackNested classes/interfaces inherited from class 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.Widget$Impl, Widget.WidgetClassNested classes/interfaces inherited from class InitiallyUnowned
InitiallyUnowned.InitiallyUnownedClassNested classes/interfaces inherited from class GObject
GObject.NotifyCallback, GObject.ObjectClassNested classes/interfaces inherited from interface Accessible
Accessible.Accessible$Impl, Accessible.AccessibleInterfaceNested classes/interfaces inherited from interface Buildable
Buildable.Buildable$Impl, Buildable.BuildableIfaceNested classes/interfaces inherited from interface CellEditable
CellEditable.CellEditable$Impl, CellEditable.CellEditableIface, CellEditable.EditingDoneCallback, CellEditable.RemoveWidgetCallbackNested classes/interfaces inherited from interface CellLayout
CellLayout.CellLayout$Impl, CellLayout.CellLayoutIfaceNested classes/interfaces inherited from interface ConstraintTarget
ConstraintTarget.ConstraintTarget$Impl, ConstraintTarget.ConstraintTargetInterface -
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.Create a new ComboBoxText.ComboBoxText(MemorySegment address) Deprecated.Create a ComboBoxText instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionvoidDeprecated.UseDropDownvoidappendText(String text) Deprecated.UseDropDownprotected ComboBoxTextasParent()Deprecated.Return this instance as if it were its parent type.static ComboBoxText.Builder<? extends ComboBoxText.Builder> builder()Deprecated.AComboBoxText.Builderobject constructs aComboBoxTextwith the specified properties.@Nullable StringDeprecated.UseDropDownstatic MemoryLayoutDeprecated.The memory layout of the native struct.static @Nullable TypegetType()Deprecated.Get the GType of the ComboBoxText class.voidDeprecated.UseDropDownvoidinsertText(int position, String text) Deprecated.UseDropDownvoidDeprecated.UseDropDownvoidprependText(String text) Deprecated.UseDropDownvoidremove(int position) Deprecated.UseDropDownvoidDeprecated.UseDropDownstatic ComboBoxTextDeprecated.UseDropDownMethods inherited from class ComboBox
activate, changed, emitActivate, emitChanged, emitFormatEntryText, emitMoveActive, emitPopdown, emitPopup, formatEntryText, getActive, getActiveId, getActiveIter, getButtonSensitivity, getChild, getEntryTextColumn, getHasEntry, getIdColumn, getModel, getPopupFixedWidth, getRowSeparatorFunc, onActivate, onChanged, onFormatEntryText, onMoveActive, onPopdown, onPopup, popdown, popup, popupForDevice, setActive, setActiveId, setActiveIter, setButtonSensitivity, setChild, setEntryTextColumn, setIdColumn, setModel, setPopupFixedWidth, setRowSeparatorFunc, withModel, withModelAndEntryMethods inherited from class 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, unsetStateFlagsMethods inherited from class 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, withPropertiesMethods inherited from class TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class ProxyInstance
equals, handle, hashCodeMethods inherited from class Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Accessible
announce, getAccessibleId, getAccessibleParent, getAccessibleRole, getAtContext, getBounds, getFirstAccessibleChild, getNextAccessibleSibling, getPlatformState, resetProperty, resetRelation, resetState, setAccessibleParent, updateNextAccessibleSibling, updatePlatformState, updateProperty, updateRelation, updateStateMethods inherited from interface Buildable
getBuildableIdMethods inherited from interface CellEditable
editingDone, emitEditingDone, emitRemoveWidget, onEditingDone, onRemoveWidget, removeWidget, startEditingMethods inherited from interface CellLayout
addAttribute, clear, clearAttributes, getArea, getCells, packEnd, packStart, reorder, setAttributes, setCellDataFunc
-
Constructor Details
-
ComboBoxText
Deprecated.Create a ComboBoxText instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
ComboBoxText
public ComboBoxText()Deprecated.Create a new ComboBoxText.
-
-
Method Details
-
getType
Deprecated.Get the GType of the ComboBoxText class.- Returns:
- the GType
-
getMemoryLayout
Deprecated.The memory layout of the native struct.- Returns:
- the memory layout
-
asParent
Deprecated.Return this instance as if it were its parent type. Comparable to the Javasuperkeyword, but ensures the parent typeclass is also used in native code. -
withEntry
Deprecated.UseDropDownCreates a newGtkComboBoxTextwith an entry.- Returns:
- a new
GtkComboBoxText
-
append
Deprecated.UseDropDownAppends
textto the list of strings stored incomboBox.If
idis non-nullthen it is used as the ID of the row.This is the same as calling
insert(int, String, String)with a position of -1.- Parameters:
id- a string ID for this valuetext- A string
-
appendText
Deprecated.UseDropDownAppends
textto the list of strings stored incomboBox.This is the same as calling
insertText(int, String)with a position of -1.- Parameters:
text- A string
-
getActiveText
Deprecated.UseDropDownReturns the currently active string in
comboBox.If no row is currently selected,
nullis returned. If this ComboBoxText contains an entry, this function will return its contents (which will not necessarily be an item from the list).- Returns:
- a newly allocated string containing the currently active text. Must be freed with g_free().
-
insert
Deprecated.UseDropDownInserts
textatpositionin the list of strings stored incomboBox.If
idis non-nullthen it is used as the ID of the row. SeeGtk.ComboBox:id-column.If
positionis negative thentextis appended.- Parameters:
position- An index to inserttextid- a string ID for this valuetext- A string to display
-
insertText
Deprecated.UseDropDownInserts
textatpositionin the list of strings stored incomboBox.If
positionis negative thentextis appended.This is the same as calling
insert(int, String, String)with anullID string.- Parameters:
position- An index to inserttexttext- A string
-
prepend
Deprecated.UseDropDownPrepends
textto the list of strings stored incomboBox.If
idis non-nullthen it is used as the ID of the row.This is the same as calling
insert(int, String, String)with a position of 0.- Parameters:
id- a string ID for this valuetext- a string
-
prependText
Deprecated.UseDropDownPrepends
textto the list of strings stored incomboBox.This is the same as calling
insertText(int, String)with a position of 0.- Parameters:
text- A string
-
remove
Deprecated.UseDropDownRemoves the string atpositionfromcomboBox.- Parameters:
position- Index of the item to remove
-
removeAll
Deprecated.UseDropDownRemoves all the text entries from the combo box. -
builder
Deprecated.AComboBoxText.Builderobject constructs aComboBoxTextwith the specified properties. Use the variousset...()methods to set properties, and finish construction withComboBoxText.Builder.build().- Returns:
- the builder object
-
DropDownwith aStringListinstead