summaryrefslogtreecommitdiff
path: root/src/window.cpp
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2009-05-30 12:41:53 +0000
committeralberth <alberth@openttd.org>2009-05-30 12:41:53 +0000
commit101a6b332064fca3fd8692360375020fcfd69324 (patch)
tree51712da823d1a48992d335045b240352ffe7e8fc /src/window.cpp
parentbfaf610fff372d6c4b0cdd887ec1997b97e8d25f (diff)
downloadopenttd-101a6b332064fca3fd8692360375020fcfd69324.tar.xz
(svn r16467) -Codechange: Unduplicate setting of widget focus (with thanks to Smatz).
Diffstat (limited to 'src/window.cpp')
-rw-r--r--src/window.cpp9
1 files changed, 2 insertions, 7 deletions
diff --git a/src/window.cpp b/src/window.cpp
index aed4065b2..f3868ccb9 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -249,11 +249,11 @@ static void StartWindowSizing(Window *w, bool to_left);
*/
static void DispatchLeftClickEvent(Window *w, int x, int y, bool double_click)
{
- bool focused_widget_changed = false;
int widget = 0;
if (w->desc_flags & WDF_DEF_WIDGET) {
widget = GetWidgetFromPos(w, x, y);
+ bool focused_widget_changed = false;
/* If clicked on a window that previously did dot have focus */
if (_focused_window != w &&
(w->desc_flags & WDF_NO_FOCUS) == 0 && // Don't lose focus to toolbars
@@ -286,12 +286,7 @@ static void DispatchLeftClickEvent(Window *w, int x, int y, bool double_click)
DeleteWindowById(WC_OSK, 0);
}
- if (w->focused_widget != wi) {
- /* Repaint the widget that lost focus. A focused edit box may else leave the caret on the screen. */
- if (w->focused_widget != NULL) w->InvalidateWidget(w->focused_widget - w->widget);
- focused_widget_changed = true;
- w->focused_widget = wi;
- }
+ focused_widget_changed = w->SetFocusedWidget(widget);
}
if (wi->type & WWB_PUSHBUTTON) {