diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-06-05 21:25:58 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-06-05 21:25:58 (GMT) |
commit | 72a4eea4cdef1059da99c87ce25a4c2db0972743 (patch) | |
tree | 6790e6d682322d159d06bb18662acb801d63725c /generic/ttk/ttkEntry.c | |
parent | ebee84d3759fbe688f9a527facf83e5dc30ae5a0 (diff) | |
parent | 329a1085f6a67610625d3e03c3650852ae5575b6 (diff) | |
download | tk-72a4eea4cdef1059da99c87ce25a4c2db0972743.zip tk-72a4eea4cdef1059da99c87ce25a4c2db0972743.tar.gz tk-72a4eea4cdef1059da99c87ce25a4c2db0972743.tar.bz2 |
merge trunk
Diffstat (limited to 'generic/ttk/ttkEntry.c')
-rw-r--r-- | generic/ttk/ttkEntry.c | 55 |
1 files changed, 46 insertions, 9 deletions
diff --git a/generic/ttk/ttkEntry.c b/generic/ttk/ttkEntry.c index b592883..38970d8 100644 --- a/generic/ttk/ttkEntry.c +++ b/generic/ttk/ttkEntry.c @@ -1742,6 +1742,16 @@ static WidgetSpec EntryWidgetSpec = { }; /*------------------------------------------------------------------------ + * Named indices for the combobox "current" command + */ +static const char *const comboboxCurrentIndexNames[] = { + "end", NULL +}; +enum comboboxCurrentIndices { + INDEX_END +}; + +/*------------------------------------------------------------------------ * +++ Combobox widget record. */ @@ -1842,15 +1852,42 @@ static int ComboboxCurrentCommand( Tcl_SetObjResult(interp, Tcl_NewIntObj(currentIndex)); return TCL_OK; } else if (objc == 3) { - if (Tcl_GetIntFromObj(interp, objv[2], ¤tIndex) != TCL_OK) { - return TCL_ERROR; - } - if (currentIndex < 0 || currentIndex >= nValues) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "Index %s out of range", Tcl_GetString(objv[2]))); - Tcl_SetErrorCode(interp, "TTK", "COMBOBOX", "IDX_RANGE", NULL); - return TCL_ERROR; - } + int result, index; + + result = Tcl_GetIndexFromObj(NULL, objv[2], comboboxCurrentIndexNames, + "", 0, &index); + if (result == TCL_OK) { + + /* + * The index is one of the named indices. + */ + + switch (index) { + case INDEX_END: + /* "end" index */ + currentIndex = nValues - 1; + break; + } + } else { + + /* + * The index should be just an integer. + */ + + if (Tcl_GetIntFromObj(NULL, objv[2], ¤tIndex) != TCL_OK) { + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "Incorrect index %s", Tcl_GetString(objv[2]))); + Tcl_SetErrorCode(interp, "TTK", "COMBOBOX", "IDX_VALUE", NULL); + return TCL_ERROR; + } + + if (currentIndex < 0 || currentIndex >= nValues) { + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "Index %s out of range", Tcl_GetString(objv[2]))); + Tcl_SetErrorCode(interp, "TTK", "COMBOBOX", "IDX_RANGE", NULL); + return TCL_ERROR; + } + } cbPtr->combobox.currentIndex = currentIndex; |