Class ComboBoxText
- All Implemented Interfaces:
Proxy
,Accessible
,Buildable
,CellEditable
,CellLayout
,ConstraintTarget
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(java.lang.String)
,
insertText(int, java.lang.String)
or
prependText(java.lang.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(org.gnome.gtk.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
Modifier and TypeClassDescriptionstatic class
ComboBoxText.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 org.gnome.gtk.ComboBox
ComboBox.ActivateCallback, ComboBox.ChangedCallback, ComboBox.ComboBoxClass, ComboBox.FormatEntryTextCallback, ComboBox.MoveActiveCallback, ComboBox.PopdownCallback, ComboBox.PopupCallback
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.Buildable
Buildable.BuildableIface, Buildable.BuildableImpl
Nested classes/interfaces inherited from interface org.gnome.gtk.CellEditable
CellEditable.CellEditableIface, CellEditable.CellEditableImpl, CellEditable.EditingDoneCallback, CellEditable.RemoveWidgetCallback
Nested classes/interfaces inherited from interface org.gnome.gtk.CellLayout
CellLayout.CellLayoutIface, CellLayout.CellLayoutImpl
Nested classes/interfaces inherited from interface org.gnome.gtk.ConstraintTarget
ConstraintTarget.ConstraintTargetImpl, ConstraintTarget.ConstraintTargetInterface
-
Constructor Summary
ConstructorDescriptionDeprecated.ComboBoxText
(MemorySegment address) Deprecated.Create a ComboBoxText proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Deprecated.UseDropDown
void
appendText
(String text) Deprecated.UseDropDown
protected ComboBoxText
asParent()
Deprecated.Returns this instance as if it were its parent type.static ComboBoxText.Builder
<? extends ComboBoxText.Builder> builder()
Deprecated.AComboBoxText.Builder
object constructs aComboBoxText
with the specified properties.Deprecated.UseDropDown
static Type
getType()
Deprecated.Get the GType of the ComboBoxText classvoid
Deprecated.UseDropDown
void
insertText
(int position, String text) Deprecated.UseDropDown
void
Deprecated.UseDropDown
void
prependText
(String text) Deprecated.UseDropDown
void
remove
(int position) Deprecated.UseDropDown
void
Deprecated.UseDropDown
static ComboBoxText
Deprecated.UseDropDown
Methods inherited from class org.gnome.gtk.ComboBox
activate, changed, emitActivate, emitChanged, emitFormatEntryText, emitMoveActive, emitPopdown, emitPopup, formatEntryText, getActive, getActiveId, getActiveIter, getButtonSensitivity, getChild, getEntryTextColumn, getHasEntry, getIdColumn, getMemoryLayout, getModel, getPopupFixedWidth, getRowSeparatorFunc, onActivate, onChanged, onFormatEntryText, onMoveActive, onPopdown, onPopup, popdown, popup, popupForDevice, setActive, setActiveId, setActiveIter, setButtonSensitivity, setChild, setEntryTextColumn, setIdColumn, setModel, setPopupFixedWidth, setRowSeparatorFunc, withModel, withModelAndEntry
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, 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, 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, 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, updateProperty, updateRelation, updateState
Methods inherited from interface org.gnome.gtk.Buildable
getBuildableId
Methods inherited from interface org.gnome.gtk.CellEditable
editingDone, emitEditingDone, emitRemoveWidget, onEditingDone, onRemoveWidget, removeWidget, startEditing
Methods inherited from interface org.gnome.gtk.CellLayout
addAttribute, clear, clearAttributes, getArea, getCells, packEnd, packStart, reorder, setAttributes, setCellDataFunc
-
Constructor Details
-
ComboBoxText
Deprecated.Create a ComboBoxText proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
ComboBoxText
-
-
Method Details
-
getType
-
asParent
Deprecated.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. -
withEntry
Deprecated.UseDropDown
Creates a newGtkComboBoxText
with an entry.- Returns:
- a new
GtkComboBoxText
-
append
Deprecated.UseDropDown
Appendstext
to the list of strings stored in this ComboBoxText.If
id
is non-null
then it is used as the ID of the row.This is the same as calling
insert(int, java.lang.String, java.lang.String)
with a position of -1.- Parameters:
id
- a string ID for this valuetext
- A string
-
appendText
Deprecated.UseDropDown
Appendstext
to the list of strings stored in this ComboBoxText.This is the same as calling
insertText(int, java.lang.String)
with a position of -1.- Parameters:
text
- A string
-
getActiveText
Deprecated.UseDropDown
Returns the currently active string in this ComboBoxText.If no row is currently selected,
null
is 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.UseDropDown
Insertstext
atposition
in the list of strings stored in this ComboBoxText.If
id
is non-null
then it is used as the ID of the row. SeeGtk.ComboBox:id-column
.If
position
is negative thentext
is appended.- Parameters:
position
- An index to inserttext
id
- a string ID for this valuetext
- A string to display
-
insertText
Deprecated.UseDropDown
Insertstext
atposition
in the list of strings stored in this ComboBoxText.If
position
is negative thentext
is appended.This is the same as calling
insert(int, java.lang.String, java.lang.String)
with anull
ID string.- Parameters:
position
- An index to inserttext
text
- A string
-
prepend
Deprecated.UseDropDown
Prependstext
to the list of strings stored in this ComboBoxText.If
id
is non-null
then it is used as the ID of the row.This is the same as calling
insert(int, java.lang.String, java.lang.String)
with a position of 0.- Parameters:
id
- a string ID for this valuetext
- a string
-
prependText
Deprecated.UseDropDown
Prependstext
to the list of strings stored in this ComboBoxText.This is the same as calling
insertText(int, java.lang.String)
with a position of 0.- Parameters:
text
- A string
-
remove
Deprecated.UseDropDown
Removes the string atposition
from this ComboBoxText.- Parameters:
position
- Index of the item to remove
-
removeAll
Deprecated.UseDropDown
Removes all the text entries from the combo box. -
builder
Deprecated.AComboBoxText.Builder
object constructs aComboBoxText
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withComboBoxText.Builder.build()
.
-
DropDown