changeset 14128:f3013e86905d draft

(svn r18675) -Add [FS#3256]: function to remove focus from all widgets in a window
author rubidium <rubidium@openttd.org>
date Thu, 31 Dec 2009 18:11:03 +0000
parents 39a257893f4c
children daeac900ff86
files src/window.cpp src/window_gui.h
diffstat 2 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -133,6 +133,18 @@
 }
 
 /**
+ * Makes no widget on this window have focus. The function however doesn't change which window has focus.
+ */
+void Window::UnfocusFocusedWidget()
+{
+	if (this->nested_focus != NULL) {
+		/* Repaint the widget that lost focus. A focused edit box may else leave the caret on the screen. */
+		this->nested_focus->SetDirty(this);
+		this->nested_focus = NULL;
+	}
+}
+
+/**
  * Set focus within this window to the given widget. The function however doesn't change which window has focus.
  * @param widget_index Index of the widget in the window to set the focus to.
  * @return Focus has changed.
--- a/src/window_gui.h
+++ b/src/window_gui.h
@@ -519,6 +519,7 @@
 		return this->GetWidget<NWidgetCore>(widget_index)->IsLowered();
 	}
 
+	void UnfocusFocusedWidget();
 	bool SetFocusedWidget(byte widget_index);
 
 	void HandleButtonClick(byte widget);