Menu

#289 Add a virtual event when GM leaves parent without slaves

open
6
2010-11-17
2009-09-20
Emiliano
No

When trying to build a custom scrolledframe one generally resorts to the <Configure> event to catch the resizing of the scrolled frame [usually a frame inside a canvas] to keep scrollbars in sync. The problem with this approach is that, when the last slave is removed from inside the frame, the geometry managers leave the frame size as-is, and the scrolled frame ends scrolling an empty region.
This can be noted in this BWidget example:
==================================================
package require BWidget

set sw [ScrolledWindow .sw]
set sf [ScrollableFrame .sf]
$sw setwidget $sf
set f [$sf getframe]

pack $sw -expand 1 -fill both -padx 10 -pady 10

for {set i 0} {$i <= 20} {incr i} {
grid \ [label $f.la$i -text "Label a order $i"] \ [label $f.lb$i -text "Label b order $i"] \ [label $f.lc$i -text "Label c order $i"]
}

after 5000 {destroy {*}[winfo children $sf]}

A way to note when the GM removes the last slave is to deliver a virtual event to the master.
This patch adds the virtual event, and is intended as a sketch of the final code (the name of the
virtual event, and whether to send additional details or not can be changed)

Discussion

  • Emiliano

    Emiliano - 2009-09-20
     
  • Emiliano

    Emiliano - 2009-09-20

    Forgot to mention, patch's code is copied almost literally from the GenerateModifiedEvent() function in generic/tkText.c

     
  • Peter Spjuth

    Peter Spjuth - 2009-09-21

    If it is the fact that a master gets empty that is important, or that it becomes
    unmanaged?
    If the latter, maybe the event should reside in the recently added
    TkFreeGeometryMaster which gets called regardless what is causing it
    to become unmanaged..

     
  • Jeffrey Hobbs

    Jeffrey Hobbs - 2009-09-21

    It is the master becoming empty, which otherwise passes no events (not even <Configure>), so Tcl-based gms like scrollableframe can't shrink accordingly. There are possibly other vevents that would make sense to generate to get rid of the reliance on <Configure> in so many apps.

     
  • Jeffrey Hobbs

    Jeffrey Hobbs - 2010-11-17
    • priority: 5 --> 6
    • assigned_to: chengyemao --> pspjuth
     
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.