Re: Tablelist and tk_messageBox interaction
- From: Csaba Nemethi <csaba.nemethi@xxxxxxxxxxx>
- Date: Wed, 01 Feb 2006 22:20:36 +0100
Jeff Godfrey schrieb:
Hi All,
I'm working on app that relies heavily on Csaba Nemethi's Tablelist widget to display database records. I have a situation where the interaction between the tablelist and a tk_messageBox seem odd to me. I'm not sure if something's broken somewhere (and if so, where), or if this is expected behavior. Here's what's happening (unfortunately, very simple to see, yet somewhat difficult to explain).
First, the tablelist's selectmode is intentionally set to "extended", so that multiple records can be selected. The app is designed so that if the current record has been modified and not saved when a new record is selected, a tk_messageBox is opened to warn the User and allow them to save the record before continuing to the newly selected record. Under normal circumstances this works as intended, except if the User does a "drag" operation during the selection of the new record. In this case, here's what happens...
1. The new record is selected with a mouse press event (but the button isn't released)
2. The app detects an unsaved record and opens the tk_messageBox in the foreground
3. As long as the mouse button hasn't been released, it's still possible to drag-select multiple record in the tablelist prior to responding to the messageBox - which is what I don't want.
Once the mouse button (pressed in #1) is released, the entire app is effectively "blocked" until the message box is handled by the User. I'd like the multi-select drag operation to blocked until the message box is handled also. I hope that made *some* sense... ;^)
So, does this indicate a problem somewhere (tablelist? tk_messagebox?), or is this considered normal behavior?
Thanks for any input.
Jeff
This behavior is hardly tablelist-specific, because tablelist widgets handle the selection exactly in the same way as the Tk listboxes. Have you tried to replace the tablelist with a listbox widget? I am pretty sure that your script will expose the same behavior.
Unfortunately, I don't have access to my Windows XP notebook right now, but I have tried to reproduce your problem on Linux and Mac OS X Aqua, with the following two scripts:
Script #1 (using a tablelist widget):
package require tablelist
toplevel .top
tablelist::tablelist .top.tbl -columns {0 Title} -selectmode extended
..top.tbl insert end 0 1 2 3 4 5 6 7 8 9
pack .top.tblbind .top.tbl <<TablelistSelect>> {
if {[lsearch [.top.tbl curselection] "4"] >= 0} {
tk_messageBox -icon error -type ok \
-message "Please save the record first!"
}
}Script #2 (using a listbox widget):
toplevel .top listbox .top.lb -selectmode extended ..top.lb insert end 0 1 2 3 4 5 6 7 8 9 pack .top.lb
bind .top.lb <<ListboxSelect>> {
if {[lsearch [.top.lb curselection] "4"] >= 0} {
tk_messageBox -icon error -type ok \
-message "Please save the record first!"
}
}Both scripts behave correctly, on both platforms. That is, once item #4 gets selected, the message box is popped up and immediately grabs the focus, blocking any further selection attempts, until it gets dismissed. Maybe on Windows XP the behavior is different; could you please verify this? Also, can you confirm that these scripts should suffice to reproduce your problem?
-- Csaba Nemethi http://www.nemethi.de mailto:csaba.nemethi@xxxxxxxxxxx .
- Follow-Ups:
- Re: Tablelist and tk_messageBox interaction
- From: Jeff Godfrey
- Re: Tablelist and tk_messageBox interaction
- References:
- Tablelist and tk_messageBox interaction
- From: Jeff Godfrey
- Tablelist and tk_messageBox interaction
- Prev by Date: Re: Finding the tagged range containing the current index in a text widget
- Next by Date: Re: http package: automatic decompression?
- Previous by thread: Tablelist and tk_messageBox interaction
- Next by thread: Re: Tablelist and tk_messageBox interaction
- Index(es):
Relevant Pages
|