mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	Disable text input on window deactivation
This commit is contained in:
		| @@ -113,10 +113,12 @@ BattleConsole::BattleConsole(const Rect & position) | ||||
| 	pos.h = position.h; | ||||
| } | ||||
|  | ||||
| BattleConsole::~BattleConsole() | ||||
| void BattleConsole::deactivate() | ||||
| { | ||||
| 	if (enteringText) | ||||
| 		setEnteringMode(false); | ||||
|  | ||||
| 	CIntObject::deactivate(); | ||||
| } | ||||
|  | ||||
| void BattleConsole::setEnteringMode(bool on) | ||||
|   | ||||
| @@ -55,12 +55,13 @@ private: | ||||
| 	/// current text entered via in-game console, takes priority over both log entries and hover text | ||||
| 	std::string consoleText; | ||||
|  | ||||
| 	/// if true then we are currently entering console text | ||||
| 	/// if true then we are currently entering console tex | ||||
| 	bool enteringText; | ||||
| public: | ||||
| 	BattleConsole(const Rect & position); | ||||
| 	~BattleConsole(); | ||||
|  | ||||
| 	void showAll(SDL_Surface * to) override; | ||||
| 	void deactivate() override; | ||||
|  | ||||
| 	bool addText(const std::string &text); //adds text at the last position; returns false if failed (e.g. text longer than 70 characters) | ||||
| 	void scrollUp(ui32 by = 1); //scrolls console up by 'by' positions | ||||
|   | ||||
| @@ -432,6 +432,14 @@ void CGStatusBar::clickLeft(tribool down, bool previousState) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| void CGStatusBar::deactivate() | ||||
| { | ||||
| 	if (enteringText) | ||||
| 		setEnteringMode(false); | ||||
|  | ||||
| 	CIntObject::deactivate(); | ||||
| } | ||||
|  | ||||
| void CGStatusBar::setOnClick(std::function<void()> handler) | ||||
| { | ||||
| 	onClick = handler; | ||||
|   | ||||
| @@ -152,6 +152,7 @@ public: | ||||
| 	void setOnClick(std::function<void()> handler); | ||||
|  | ||||
| 	void show(SDL_Surface * to) override; | ||||
| 	void deactivate() override; | ||||
|  | ||||
| 	// IStatusBar interface | ||||
| 	void write(const std::string & Text) override; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user