Tk Source Code

View Ticket
Login
Ticket UUID: 220543
Title: Must click twice on menus of inactive windows
Type: Bug Version: obsolete: 8.0.4
Submitter: welch Created on: 2000-10-31 23:44:21
Subsystem: 68. Win Window Operations Assigned To: nobody
Priority: 2 Severity:
Status: Closed Last Modified: 2001-03-24 07:12:18
Resolution: Fixed Closed By: dgp
    Closed on: 2001-03-24 00:12:18
Description:
OriginalBugID: 2272 Bug
Version: 8.0.4
SubmitDate: '1999-06-21'
LastModified: '2000-04-14'
Severity: MED
Status: Released
Submitter: techsupp
ChangedBy: hobbs
OS: Windows NT
OSVersion: 4.0
Machine: X86
FixedDate: '2000-04-14'
FixedInVersion: 8.3.1


Name:
Brian Griffin

CVS:
core-8-0-4

Extensions:
Tix4.1, [incrTcl]3.0, gdi, printer

CustomShell:
Several.  Don't recall exactly which ones.

Comments:
This is a bug only for menus and not other Tk widgets because the menu
    is not under Tk's control.  By delaying the window activation, the mouse
    down event gets consumed by Tk and the Menu never sees it.  This can
    also be a problem with any other widgets that are implemented in the
    native form.
    
    The stated reason for delaying the window activation event is so that a
    test for active grabs can be done.  This must be done immediately
    otherwise the native widgets will not work correctly.

ReproducibleScript:
# Execute the following in wish
    # Try to select the Test (or Test2) menu in the inactive window
    # The first mouse click will activate the window, but will not activate
    the
    # menu.  The second mouse click will activate the menu.
    # Then try this same experiment with any non-Tk based Windows
    application.
    menu .mbar
    . configure -menu .mbar
    .mbar add cascade -label Test -menu .mbar.test
    menu .mbar.test
    .mbar.test add command -label Echo -command {puts test}
    toplevel .foo
    menu .foo.mbar
    .foo configure -menu .foo.mbar
    .foo.mbar add cascade -label Test2 -menu .foo.mbar.test2
    menu .foo.mbar.test2
    .foo.mbar.test2 add command -label Echo2 -command {puts test2}

ObservedBehavior:
This is a Windows only problem:
    Selecting a menu in an inactive Tk toplevel window requires two mouse
    clicks.  This is not the case for any other non-Tk based Windows
    application.

DesiredBehavior:
A single mouse click should both activate the window and select the
    menu.

Patch:
cvs diff tkWinWm.c      
Index: tkWinWm.c
===================================================================
RCS file: /cvsroot/tk/win/tkWinWm.c,v
retrieving revision 1.5
diff -r1.5 tkWinWm.c
4007a4008,4012
>               if (winPtr && (TkGrabState(winPtr) != TK_GRAB_EXCLUDED)) {
>                       result = DefWindowProc(hwnd, message, wParam, lParam);
>                       goto done;
>               }
> 
4009,4010c4014,4015
<            * Don't activate the window yet since there may be grabs
<            * that should take precedence.  Instead we need to queue
---
>            * Don't activate the window yet since there is a grab
>            * that takes precedence.  Instead we need to queue

PatchFiles:
tkWinWm.c



Although the patch line indicators point to the WM_CHITTEST
message, this seems to work correctly when placed in the
WM_MOUSEACTIVATE switch (which seem logical anyway).  Perhaps
a blooper based on other changes in the file.

This has been added for 8.3.1. 
-- 04/14/2000 hobbs