Browse Source

notFocusedClick refactoring

Laserlicht 1 year ago
parent
commit
ca037aae33

+ 4 - 16
client/lobby/OptionsTab.cpp

@@ -765,9 +765,9 @@ void OptionsTab::SelectionWindow::sliderMove(int slidPos)
 	redraw();
 }
 
-bool OptionsTab::SelectionWindow::receiveEvent(const Point & position, int eventType) const
+void OptionsTab::SelectionWindow::notFocusedClick()
 {
-	return true;  // capture click also outside of window
+	close();
 }
 
 void OptionsTab::SelectionWindow::clickReleased(const Point & cursorPosition)
@@ -775,12 +775,6 @@ void OptionsTab::SelectionWindow::clickReleased(const Point & cursorPosition)
 	if(slider && slider->pos.isInside(cursorPosition))
 		return;
 
-	if(!pos.isInside(cursorPosition))
-	{
-		close();
-		return;
-	}
-
 	int elem = getElement(cursorPosition);
 
 	setElement(elem, true);
@@ -898,15 +892,9 @@ OptionsTab::HandicapWindow::HandicapWindow()
 	center();
 }
 
-bool OptionsTab::HandicapWindow::receiveEvent(const Point & position, int eventType) const
+void OptionsTab::HandicapWindow::notFocusedClick()
 {
-	return true;  // capture click also outside of window
-}
-
-void OptionsTab::HandicapWindow::clickReleased(const Point & cursorPosition)
-{
-	if(!pos.isInside(cursorPosition)) // make it possible to close window by touching/clicking outside of window
-		close();
+	close();
 }
 
 OptionsTab::SelectedBox::SelectedBox(Point position, PlayerSettings & playerSettings, SelType type)

+ 2 - 3
client/lobby/OptionsTab.h

@@ -63,8 +63,7 @@ public:
 		std::map<PlayerColor, std::map<EGameResID, std::shared_ptr<CTextInput>>> textinputs;
 		std::vector<std::shared_ptr<CButton>> buttons;
 
-		bool receiveEvent(const Point & position, int eventType) const override;
-		void clickReleased(const Point & cursorPosition) override;
+		void notFocusedClick() override;
 	public:
 		HandicapWindow();
 	};
@@ -167,7 +166,7 @@ private:
 
 		void sliderMove(int slidPos);
 
-		bool receiveEvent(const Point & position, int eventType) const override;
+		void notFocusedClick() override;
 		void clickReleased(const Point & cursorPosition) override;
 		void showPopupWindow(const Point & cursorPosition) override;
 

+ 2 - 2
client/windows/GUIClasses.cpp

@@ -1703,7 +1703,7 @@ void VideoWindow::keyPressed(EShortcut key)
 	exit(true);
 }
 
-bool VideoWindow::receiveEvent(const Point & position, int eventType) const
+void VideoWindow::notFocusedClick()
 {
-	return true;  // capture click also outside of window
+	exit(true);
 }

+ 1 - 1
client/windows/GUIClasses.h

@@ -523,5 +523,5 @@ public:
 
 	void clickPressed(const Point & cursorPosition) override;
 	void keyPressed(EShortcut key) override;
-	bool receiveEvent(const Point & position, int eventType) const override;
+	void notFocusedClick() override;
 };