Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#2596 ttk::entry xview sub-command forces use of update idletasks

obsolete: 8.5.5
open
Joe English
5
2009-01-16
2009-01-16
Colin McDonald
No

Before the ttk::entry xview sub-command is invoked, an
update idletasks command must be executed in order to
update the entry scrolling information, otherwise the
sub-command doesn't work correctly e.g. the following
script is supposed to set an entry field value and
then scroll it to the end ready for editing:

pack [ttk::entry .e -width 8]
.e insert end abcdefghijklmnopqrstuvwxyz
.e xview [.e index end]

The field is left unscrolled, unless update idletasks
is inserted before the xview sub-command.

The use of update and update idletasks is generally
discouraged on comp.lang.tcl, unless *absolutely
necessary*, for well known reasons. Recursively
re-entering the event loop can lead to application
logic problems, the widget may have been destroyed,
etc. I don't think that it is desirable for a core
widget to force use of update idletasks just to
function correctly. It is particularly a nuisance if
a whole form of entry fields is being set ready for
modification.

The following change to generic/ttk/ttkEntry.c will
avoid the problem:

static int EntryXViewCommand(
Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr)
{
Entry *entryPtr = recordPtr;

/* If caller has requested that the widget view is
* adjusted to a given index "pathName xview index",
* then ensure that the scroll info is up-to-date.
*/

if (objc == 3) {
EntryDoLayout(recordPtr);
}

return TtkScrollviewCommand(interp, objc, objv,
entryPtr->entry.xscrollHandle);
}

Proc ttk::entry::See in library/ttk/entry.tcl can then
also be modified to remove an update idletasks.

Discussion

  • Colin McDonald
    Colin McDonald
    2009-01-16

    • milestone: --> obsolete: 8.5.5