TIP 675: Control cursor blinking cycle in Ttk widgets.

Login
    Author:        Francois Vogel <[email protected]>
    State:         Final
    Type:          Project
    Vote:          Done
    Vote-Summary:  4/0/0
    Votes-For:     BG, SL, FV, KW
    Votes-Against: none
    Votes-Present: none
    Created:       13-Jun-2023
    Tcl-Version:   8.7
    Keywords:      Tk, Ttk, cursor, blink
    Tk-Branch:     tip-675

Abstract

This TIP adds script-level control on the on and off times of the insertion cursor of Ttk widgets.

Rationale

From time to time people have been requesting control on the blink cycle of the insertion cursor displayed by certain widgets (entry, spinbox, combobox). Tk provides this feature for a very long time, but Ttk currently doesn't.

See for instance tickets 3531366fff and c7046ba187, and in the newsgroup here and there.

The most wanted feature is to have a mean to switch cursor blinking entirely off, because some people cannot work with blinking cursors.

Specification

New style defaults "-insertontime" and "-insertofftime" can be set, controlling application-wide cursor blinking times in all Ttk widgets. Values are in milliseconds.

Setting "-insertofftime" to 0 switches blinking off.

Example

package require Tk
pack [ttk::entry .ee]    ; # cursor blinks
focus -force .ee         ; # see cursor blinking
ttk::style configure . -insertofftime 0  ; # stop cursor blinking

Alternatives

A - Instead of style defaults, get the values from the user preferences

In ticket 3531366fff, and also in 1dc430ad59, it has been proposed to get the on/off times from the platform environment settings (in the window manager). While respecting user's preferences sounds like a good idea, I believe it sets too high a bar. Retrieving the values from Linux environments is not trivial (see the patches in the first mentioned ticket), and I'm afraid maintenance of such code would be cumbersome. Tk doesn't do that either. As a first step at least, I propose not to bother with the platform settings and let users and script programmers to set their values through:

ttk::style configure . -insertofftime myOFFtime -insertontime myONtime

B - Create a new command instead of using a style default

For instance one could imagine a new subcommand in the "tk" command:

tk ttkinserttimes ?value value?

or a new "ttk" command mimicking the behaviour of the "tk" command:

ttk inserttimes ?value value?

but I felt more natural to go for a style default just like all of the other defaults Ttk uses.

Implementation

See branch tip-675

Post-vote note

Following discussion on the Tcl Core mailing list, the possibility of overriding the on and off default times with values obtained from the option database (if such values are specified) has been added after the TIP was voted YES.

Copyright

This document has been placed in the public domain.