summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2009-09-11 18:54:33 +0000
committeralberth <alberth@openttd.org>2009-09-11 18:54:33 +0000
commite1ae20a30740f652906f85c1f82cac85c66e9525 (patch)
tree447989be93ddf12f17add08dd88ac4f3e31e3f3f
parent669b7d01acb603ebea3071b347f7b0cec8b9f505 (diff)
downloadopenttd-e1ae20a30740f652906f85c1f82cac85c66e9525.tar.xz
(svn r17503) -Fix (r17502): Save all files before commit.
-rw-r--r--src/window_gui.h31
1 files changed, 24 insertions, 7 deletions
diff --git a/src/window_gui.h b/src/window_gui.h
index 80819a9d3..2e8b12a4a 100644
--- a/src/window_gui.h
+++ b/src/window_gui.h
@@ -503,16 +503,33 @@ public:
*/
inline bool SetFocusedWidget(byte widget_index)
{
- if (widget_index >= this->widget_count || this->widget + widget_index == this->focused_widget) {
- return false;
+ if (this->widget != NULL) {
+ /* Do nothing if widget_index is already focused, or if it wasn't a valid widget. */
+ if (widget_index >= this->widget_count || this->widget + widget_index == this->focused_widget) return false;
+
+ if (this->focused_widget != NULL) {
+ /* Repaint the widget that lost focus. A focused edit box may else leave the caret on the screen. */
+ this->InvalidateWidget(this->focused_widget - this->widget);
+ }
+ this->focused_widget = &this->widget[widget_index];
+ return true;
}
- if (this->focused_widget != NULL) {
- /* Repaint the widget that lost focus. A focused edit box may else leave the caret on the screen. */
- this->InvalidateWidget(this->focused_widget - this->widget);
+ if (this->nested_array != NULL) {
+ /* Do nothing if widget_index is already focused, or if it wasn't a valid widget. */
+ if (widget_index >= this->nested_array_size) return false;
+
+ assert(this->nested_array[widget_index] != NULL); // Setting focus to a non-existing widget is a bad idea.
+ if (this->nested_focus != NULL) {
+ if (this->nested_array[widget_index] == this->nested_focus) return false;
+
+ /* Repaint the widget that lost focus. A focused edit box may else leave the caret on the screen. */
+ this->nested_focus->Invalidate(this);
+ }
+ this->nested_focus = this->nested_array[widget_index];
+ return true;
}
- this->focused_widget = &this->widget[widget_index];
- return true;
+ NOT_REACHED();
}
/**