public class ComboBoxText extends ComboBox
A common use case for ComboBoxes is to just choose from
a list of textual options. This subclass of ComboBox takes care of the
mechanics of setting up a the ListStore and the appropriate CellRenderers
so as to allow a straight forward interface with a limited number of
convenience methods for adding Strings.
Usage is very straight forward:
combo = new TextComboBox();
combo.appendText("SYD");
combo.appendText("YYZ");
combo.appendText("JFK");
combo.appendText("LHR");
...
You can still use the getActive() from
ComboBox, but for simple lists of Strings being displayed be this Widget,
the String specific getActiveText() that is
introduced here is probably what you want.ComboBox.ChangedWidget.ButtonPressEvent, Widget.ButtonReleaseEvent, Widget.Destroy, Widget.Draw, Widget.EnterNotifyEvent, Widget.FocusInEvent, Widget.FocusOutEvent, Widget.Hide, Widget.KeyPressEvent, Widget.KeyReleaseEvent, Widget.LeaveNotifyEvent, Widget.MapEvent, Widget.MotionNotifyEvent, Widget.PopupMenu, Widget.QueryTooltip, Widget.ScrollEvent, Widget.SizeAllocate, Widget.UnmapEvent, Widget.VisibilityNotifyEvent| Constructor and Description |
|---|
ComboBoxText()
Construct a new text-only ComboBox.
|
| Modifier and Type | Method and Description |
|---|---|
void |
appendText(String text)
Append an item to the list.
|
String |
getActiveText()
Returns the text of the active item.
|
void |
insertText(int position,
String text)
Append an item at the supplied position.
|
void |
prependText(String text)
Prepend an item to the beginning of the list.
|
void |
removeText(int position)
Removes the item at given position from the list.
|
void |
setModel(TreeModel model)
Unsupported.
|
connect, getActive, getActiveIter, popdown, popup, setActive, setActiveIteradd, getChildren, remove, setBorderWidthactivate, addEvents, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, destroy, getAllocatedHeight, getAllocatedWidth, getAllocation, getCanDefault, getCanFocus, getHasFocus, getName, getParent, getPreferredHeightForWidthMinimum, getPreferredHeightForWidthNatural, getPreferredHeightMinimum, getPreferredHeightNatural, getPreferredWidthForHeightMinimum, getPreferredWidthForHeightNatural, getPreferredWidthMinimum, getPreferredWidthNatural, getRequestMode, getRequisition, getSensitive, getStyleContext, getToplevel, getWindow, grabAdd, grabDefault, grabFocus, grabRemove, hide, isSensitive, overrideBackground, overrideColor, overrideFont, queueDraw, queueDrawArea, realize, setAlignHorizontal, setAlignVertical, setCanDefault, setCanFocus, setEvents, setExpandHorizontal, setExpandVertical, setName, setSensitive, setSizeRequest, setTooltipMarkup, setTooltipText, show, showAllpublic ComboBoxText()
public void appendText(String text)
public String getActiveText()
public void insertText(int position,
String text)
public void prependText(String text)
public void removeText(int position)
public void setModel(TreeModel model)
If you're using a text mode ComboBox, GTK internally allocates a ListStore of a certain structure and the methods are designed to work against it. Things will blow up if you swap it for something different, unless it had exactly the correct signature. As this signature is not something that is part of the GTK API, it is not something we're going to expose; this override is here to prevent you from shooting yourself in the foot.