Tk Source Code

View Ticket
Login
Ticket UUID: 220908
Title: Clicking application windows fails to raise dialogs when a g
Type: Bug Version: obsolete: 8.3
Submitter: welch Created on: 2000-11-01 01:30:59
Subsystem: 68. Win Window Operations Assigned To: hobbs
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2004-09-11 01:42:30
Resolution: Fixed Closed By: hobbs
    Closed on: 2004-09-10 06:37:17
Description:
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.
User Comments: hobbs added on 2004-09-11 01:42:30:
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.

hobbs added on 2004-09-10 13:37:17:
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.