mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	Added right click pop-up for text inputs
This commit is contained in:
		| @@ -565,6 +565,8 @@ std::shared_ptr<CTextInput> InterfaceObjectConfigurable::buildTextInput(const Js | ||||
| 		result->setText(readText(config["text"])); | ||||
| 	if(!config["callback"].isNull()) | ||||
| 		result->cb += callbacks_string.at(config["callback"].String()); | ||||
| 	if(!config["help"].isNull()) | ||||
| 		result->helpBox = readText(config["help"]); | ||||
| 	return result; | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -61,7 +61,7 @@ OptionsTab::OptionsTab() : humanPlayers(0) | ||||
| 	auto parseTimerString = [](const std::string & str){ | ||||
| 		auto sc = str.find(":"); | ||||
| 		if(sc == std::string::npos) | ||||
| 			return std::stoi(str); | ||||
| 			return str.empty() ? 0 : std::stoi(str); | ||||
| 		 | ||||
| 		auto l = str.substr(0, sc); | ||||
| 		auto r = str.substr(sc + 1, std::string::npos); | ||||
| @@ -75,6 +75,8 @@ OptionsTab::OptionsTab() : humanPlayers(0) | ||||
| 			r.insert(r.begin(), l.back()); | ||||
| 			l.pop_back(); | ||||
| 		} | ||||
| 		else if(r.empty()) | ||||
| 			r = "0"; | ||||
| 		 | ||||
| 		int sec = std::stoi(r); | ||||
| 		if(sec >= 60) | ||||
|   | ||||
| @@ -17,6 +17,7 @@ | ||||
| #include "../gui/CGuiHandler.h" | ||||
| #include "../gui/Shortcut.h" | ||||
| #include "../windows/CMessage.h" | ||||
| #include "../windows/InfoWindows.h" | ||||
| #include "../adventureMap/CInGameConsole.h" | ||||
| #include "../renderSDL/SDL_Extensions.h" | ||||
| #include "../render/Canvas.h" | ||||
| @@ -495,7 +496,7 @@ CTextInput::CTextInput(const Rect & Pos, EFonts font, const CFunctionList<void(c | ||||
| 	pos.h = Pos.h; | ||||
| 	pos.w = Pos.w; | ||||
| 	background.reset(); | ||||
| 	addUsedEvents(LCLICK | KEYBOARD | TEXTINPUT); | ||||
| 	addUsedEvents(LCLICK | SHOW_POPUP | KEYBOARD | TEXTINPUT); | ||||
|  | ||||
| #if !defined(VCMI_MOBILE) | ||||
| 	giveFocus(); | ||||
| @@ -511,7 +512,7 @@ CTextInput::CTextInput(const Rect & Pos, const Point & bgOffset, const std::stri | ||||
|  | ||||
| 	OBJ_CONSTRUCTION; | ||||
| 	background = std::make_shared<CPicture>(bgName, bgOffset.x, bgOffset.y); | ||||
| 	addUsedEvents(LCLICK | KEYBOARD | TEXTINPUT); | ||||
| 	addUsedEvents(LCLICK | SHOW_POPUP | KEYBOARD | TEXTINPUT); | ||||
|  | ||||
| #if !defined(VCMI_MOBILE) | ||||
| 	giveFocus(); | ||||
| @@ -604,6 +605,13 @@ void CTextInput::keyPressed(EShortcut key) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| void CTextInput::showPopupWindow(const Point & cursorPosition) | ||||
| { | ||||
| 	if(helpBox.size()) //there is no point to show window with nothing inside... | ||||
| 		CRClickPopup::createAndPush(helpBox); | ||||
| } | ||||
|  | ||||
|  | ||||
| void CTextInput::setText(const std::string & nText) | ||||
| { | ||||
| 	setText(nText, false); | ||||
|   | ||||
| @@ -213,6 +213,8 @@ protected: | ||||
| 	std::string visibleText() override; | ||||
|  | ||||
| public: | ||||
| 	std::string helpBox; //for right-click help | ||||
| 	 | ||||
| 	CFunctionList<void(const std::string &)> cb; | ||||
| 	CFunctionList<void(std::string &, const std::string &)> filters; | ||||
| 	void setText(const std::string & nText) override; | ||||
| @@ -224,6 +226,7 @@ public: | ||||
|  | ||||
| 	void clickPressed(const Point & cursorPosition) override; | ||||
| 	void keyPressed(EShortcut key) override; | ||||
| 	void showPopupWindow(const Point & cursorPosition) override; | ||||
|  | ||||
| 	//bool captureThisKey(EShortcut key) override; | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user