Browse Source

VisualTests: Activate keyboard when activating "go to" feature (Ctrl + G)

Michael Ragazzon 11 months ago
parent
commit
5ecc8e6dd1

+ 19 - 5
Tests/Source/VisualTests/TestNavigator.cpp

@@ -35,6 +35,7 @@
 #include <RmlUi/Core/Element.h>
 #include <RmlUi/Core/Element.h>
 #include <RmlUi/Core/ElementDocument.h>
 #include <RmlUi/Core/ElementDocument.h>
 #include <RmlUi/Core/Math.h>
 #include <RmlUi/Core/Math.h>
+#include <RmlUi/Core/SystemInterface.h>
 #include <Shell.h>
 #include <Shell.h>
 #include <cstdio>
 #include <cstdio>
 
 
@@ -257,7 +258,7 @@ void TestNavigator::ProcessEvent(Rml::Event& event)
 			}
 			}
 			else if (goto_index >= 0)
 			else if (goto_index >= 0)
 			{
 			{
-				goto_index = -1;
+				CancelGoTo();
 				UpdateGoToText();
 				UpdateGoToText();
 			}
 			}
 		}
 		}
@@ -269,9 +270,9 @@ void TestNavigator::ProcessEvent(Rml::Event& event)
 		{
 		{
 			if (goto_index < 0)
 			if (goto_index < 0)
 			{
 			{
-				goto_index = 0;
-				UpdateGoToText();
 				element_filter_input->Blur();
 				element_filter_input->Blur();
+				StartGoTo();
+				UpdateGoToText();
 			}
 			}
 		}
 		}
 	}
 	}
@@ -340,7 +341,7 @@ void TestNavigator::ProcessEvent(Rml::Event& event)
 		else if (goto_index >= 0 && key_identifier == Rml::Input::KI_BACK)
 		else if (goto_index >= 0 && key_identifier == Rml::Input::KI_BACK)
 		{
 		{
 			if (goto_index <= 0)
 			if (goto_index <= 0)
-				goto_index = -1;
+				CancelGoTo();
 			else
 			else
 				goto_index = goto_index / 10;
 				goto_index = goto_index / 10;
 
 
@@ -371,7 +372,7 @@ void TestNavigator::ProcessEvent(Rml::Event& event)
 						out_of_bounds = true;
 						out_of_bounds = true;
 				}
 				}
 
 
-				goto_index = -1;
+				CancelGoTo();
 				UpdateGoToText(out_of_bounds);
 				UpdateGoToText(out_of_bounds);
 			}
 			}
 		}
 		}
@@ -592,6 +593,19 @@ void TestNavigator::StopTestSuiteIteration()
 	LoadActiveTest();
 	LoadActiveTest();
 }
 }
 
 
+void TestNavigator::StartGoTo()
+{
+	goto_index = 0;
+	const Rml::Rectanglef area = viewer->GetGoToArea();
+	Rml::GetSystemInterface()->ActivateKeyboard(area.TopLeft(), area.Height());
+}
+
+void TestNavigator::CancelGoTo()
+{
+	Rml::GetSystemInterface()->DeactivateKeyboard();
+	goto_index = -1;
+}
+
 void TestNavigator::UpdateGoToText(bool out_of_bounds)
 void TestNavigator::UpdateGoToText(bool out_of_bounds)
 {
 {
 	if (out_of_bounds)
 	if (out_of_bounds)

+ 2 - 0
Tests/Source/VisualTests/TestNavigator.h

@@ -63,6 +63,8 @@ private:
 	void StartTestSuiteIteration(IterationState iteration_state);
 	void StartTestSuiteIteration(IterationState iteration_state);
 	void StopTestSuiteIteration();
 	void StopTestSuiteIteration();
 
 
+	void StartGoTo();
+	void CancelGoTo();
 	void UpdateGoToText(bool out_of_bounds = false);
 	void UpdateGoToText(bool out_of_bounds = false);
 
 
 	void ShowReference(ReferenceState new_reference_state);
 	void ShowReference(ReferenceState new_reference_state);

+ 7 - 0
Tests/Source/VisualTests/TestViewer.cpp

@@ -345,6 +345,13 @@ void TestViewer::SetGoToText(const Rml::String& rml)
 	description_goto->SetInnerRML(rml);
 	description_goto->SetInnerRML(rml);
 }
 }
 
 
+Rml::Rectanglef TestViewer::GetGoToArea() const
+{
+	Element* description_goto = document_description->GetElementById("goto");
+	RMLUI_ASSERT(description_goto);
+	return Rml::Rectanglef::FromPositionSize(description_goto->GetAbsoluteOffset(), description_goto->GetBox().GetSize());
+}
+
 void TestViewer::SetAttention(bool active)
 void TestViewer::SetAttention(bool active)
 {
 {
 	if (active)
 	if (active)

+ 1 - 0
Tests/Source/VisualTests/TestViewer.h

@@ -53,6 +53,7 @@ public:
 		int filtered_number_of_tests, int suite_index, int number_of_suites, bool keep_scroll_position = false);
 		int filtered_number_of_tests, int suite_index, int number_of_suites, bool keep_scroll_position = false);
 
 
 	void SetGoToText(const Rml::String& rml);
 	void SetGoToText(const Rml::String& rml);
+	Rml::Rectanglef GetGoToArea() const;
 
 
 	void SetAttention(bool active);
 	void SetAttention(bool active);