OriginalBugID: 5040 RFE
Version: 8.3
SubmitDate: '2000-04-12'
LastModified: '2000-09-06'
Severity: MED
Status: UnAssn
Submitter: shawn
ChangedBy: hobbs
RelatedBugIDs: 4609
OS: Windows NT
When a dialog has a local grab and the window is hidden clicking in other toplevel windows doesn't raise the dialog. I understand that this is that this is by design - as I understand it from reading the help. It would be nice however if a mouse event(click - I am thinking - possibly enter) in other parts of the application would raise the application.
to reproduce:
Run tkerror at the command line in an interactive shell - Hide the popup dialog. Click on the main window for the application - nothing happens.
I expect the dialog to raise.
Logged In: YES
user_id=72656
If you want have outside windows respond when you 'grab' a
window, you need something like this:
proc grabwatch {w X Y} {
set in [winfo containing $X $Y]
puts "Received <1> in '$in' by $w"
if {![string match $w* $in]} {
# $in may be "" if we hit a titlebar
if {![winfo exists $in]} { set in $w }
# outside grab hierarchy - raise the window, which will
# bring our grab window with it
raise [winfo toplevel $in]
# then force focus into the grabbing window
focus -force $w
}
}
and in your code:
bind [winfo toplevel $widget] <1> [list grabwatch %W %X %Y]
grab $widget
# wait till your grab is done somehow
bind [winfo toplevel $widget] <1> {}
This works because during a grab, all mouse events go to the
grabbing widget.
Logged In: YES
user_id=72656
It turns out that this is better handled as a default Tk
behavior, and can be done by forcing SetFocus on the grab
window when it exists, instead of just ignoring SetFocus if
the current window was grab excluded (in
tkWinWm.c:ActivateWindow). Corrected for 8.4.8 and 8.5.