Ticket #10792: 0001-Fix-window-behavior-when-default-button-is-present.patch

File 0001-Fix-window-behavior-when-default-button-is-present.patch, 1.5 KB (added by KapiX, 10 years ago)
  • src/kits/interface/Window.cpp

    From fd8dd5693671a2a12d6d02fce9d7759543aeb548 Mon Sep 17 00:00:00 2001
    From: Kacper Kasper <kacperkasper@gmail.com>
    Date: Mon, 28 Apr 2014 10:26:51 +0000
    Subject: [PATCH] Fix window behavior when default button is present
    
    * Don't intercept Enter key press in a window when there is default
    button and another BControl focused.
    * Current behavior was basically breaking every window using default
    button. Even if there was a button focused (using Tab key), when Enter
    was hit, default button handled the message, therefore instead of
    i.e. 'Revert' 'Apply' was pressed.
    * Fixes #10792.
    ---
     src/kits/interface/Window.cpp | 6 ++++--
     1 file changed, 4 insertions(+), 2 deletions(-)
    
    diff --git a/src/kits/interface/Window.cpp b/src/kits/interface/Window.cpp
    index f23681f..f315dac 100644
    a b  
    11/*
    2  * Copyright 2001-2011, Haiku.
     2 * Copyright 2001-2014, Haiku.
    33 * Distributed under the terms of the MIT License.
    44 *
    55 * Authors:
    BWindow::_DetermineTarget(BMessage* message, BHandler* target)  
    32873287        case B_KEY_UP:
    32883288        {
    32893289            // if we have a default button, it might want to hear
    3290             // about pressing the <enter> key
     3290            // about pressing the <enter> key, but it shouldn't
     3291            // intercept it if another BControl is focused
    32913292            int32 rawChar;
    32923293            if (DefaultButton() != NULL
     3294                && dynamic_cast<BControl*>(CurrentFocus()) == NULL
    32933295                && message->FindInt32("raw_char", &rawChar) == B_OK
    32943296                && rawChar == B_ENTER)
    32953297                return DefaultButton();