From a18a6b78143b5f399a00d03db1ede6d1f8776de0 Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 16 Mar 2016 16:15:05 +0000 Subject: Fixed bug [1192095] (issue 2) - Toplevel menus return incorrect active index --- win/tkWinMenu.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c index 4593928..4478dd6 100644 --- a/win/tkWinMenu.c +++ b/win/tkWinMenu.c @@ -1287,7 +1287,17 @@ TkWinHandleMenuEvent( if (menuPtr != NULL) { long entryIndex = LOWORD(*pwParam); - mePtr = NULL; + if ((menuPtr->menuType == MENUBAR) && menuPtr->tearoff) { + /* + * Windows passes the entry index starting at 0 for + * the first menu entry. However this entry #0 is the + * tearoff entry for Tk (the menu has -tearoff 1), + * which is ignored for MENUBAR menues on Windows. + */ + + entryIndex++; + } + mePtr = NULL; if (flags != 0xFFFF) { if ((flags&MF_POPUP) && (entryIndexnumEntries)) { mePtr = menuPtr->entries[entryIndex]; -- cgit v0.12