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
|
|
1 | 1 | /* |
2 | | * Copyright 2001-2011, Haiku. |
| 2 | * Copyright 2001-2014, Haiku. |
3 | 3 | * Distributed under the terms of the MIT License. |
4 | 4 | * |
5 | 5 | * Authors: |
… |
… |
BWindow::_DetermineTarget(BMessage* message, BHandler* target)
|
3287 | 3287 | case B_KEY_UP: |
3288 | 3288 | { |
3289 | 3289 | // 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 |
3291 | 3292 | int32 rawChar; |
3292 | 3293 | if (DefaultButton() != NULL |
| 3294 | && dynamic_cast<BControl*>(CurrentFocus()) == NULL |
3293 | 3295 | && message->FindInt32("raw_char", &rawChar) == B_OK |
3294 | 3296 | && rawChar == B_ENTER) |
3295 | 3297 | return DefaultButton(); |