Menu

#159 Improved binding for listboxes in extended selection mode

open
5
2004-05-27
2004-05-25
No

Improved binding for listboxes in extended selection mode

A typical usage of a listbox in extended selection mode
is the extending of the selection by pressing the
<Shift> button in combination with hitting the <Up> an
<Down> arrow keys or pressing the <B1> mouse button.
The listbox behaviour for these actions is defined in
the proc tk::ListBoxMotion, which can be found in the
file listbox.tcl in the Tk library.

Especially for this specific behaviour, the revised
proc tk::ListBoxMotion below exhibits considerable
improvements in execution speed and display handling.

The revised proc has also been submitted as a patch to
sourceforge. I post it here to c.l.t for those among
the newsgroup readers who want to try it in an early stage.

Sincerely,

Erik Leunissen
--------------

Summary of improvements

a. Changing the selection on various incontiguous
selected/deselected ranges with <Shift-B1>:
Reduction of execution time in the order of 25 - 33%
(1.33 - 1.5 times faster)

b. Changing (extending/reducing) the selection by a
single item through <Shift-Up>, <Shift-Down> or
dragging the mouse one item with <Shift-B1> pressed:
Reduction of execution time in the order of 50 - 70%
(2 - 3.5 times faster)

c. As in b. but for the special case that the action
doesn't change the selection state of the item under
the pointer:
Reduction of execution time in the order of 99 -
99.3% (100 - 150 times faster)

With respect to cases b and c:
Using the standard Tk bindings for listboxes in
combination with hardware (CPU and video card) that is
nothing special, an item immediately adjacent to the
item that to be (de)selected could be seen to flicker
for a moment. With the revised code, the flicker is gone.

Erik Leunissen

Discussion

  • Erik Leunissen

    Erik Leunissen - 2004-05-26
     
  • Erik Leunissen

    Erik Leunissen - 2004-05-26

    Logged In: YES
    user_id=113903

    There is one more location in listbox.tcl where the display
    handling can be improved. The suplied revision for
    tk::ListboxBeginSelect prevents that the selected item
    flickers on the display. File attached file
    ListboxBeginSelect.tcl holds this revision.

    Erik Leunissen

     
  • Erik Leunissen

    Erik Leunissen - 2004-05-26
     
  • Donal K. Fellows

    • labels: --> 09. [listbox]
    • assigned_to: nobody --> hobbs
     
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.