Example #1
0
File: ui.cpp Project: Ryozuki/ddnet
void CUI::AndroidBlockAndGetTextInput(char *text, int textLength, const char *hintText)
{
#if defined(__ANDROID__)
	SDL_ANDROID_SetScreenKeyboardHintMesage(hintText);
	SDL_ANDROID_GetScreenKeyboardTextInput(text, textLength);
#endif
}
Example #2
0
/**
 * @brief Called when the node got the focus
 */
void uiTextEntryNode::onFocusGained (uiNode_t* node)
{
	assert(editedCvar == nullptr);
	/* skip '*cvar ' */
	const char* cvarRef = "*cvar:";
	editedCvar = Cvar_Get(&((const char*)node->text)[strlen(cvarRef)]);
	assert(editedCvar);
	Q_strncpyz(cvarValueBackup, editedCvar->string, sizeof(cvarValueBackup));
	isAborted = false;
	EXTRADATA(node).cursorPosition = UTF8_strlen(editedCvar->string);

#if SDL_VERSION_ATLEAST(2,0,0)
	SDL_StartTextInput();
	vec2_t pos;
	UI_GetNodeAbsPos(node, pos);
	SDL_Rect r = {static_cast<int>(pos[0]), static_cast<int>(pos[1]), static_cast<int>(node->box.size[0]), static_cast<int>(node->box.size[1])};
	SDL_SetTextInputRect(&r);
#else
#ifdef ANDROID
	char buf[MAX_CVAR_EDITING_LENGTH];
	Q_strncpyz(buf, editedCvar->string, sizeof(buf));
	SDL_ANDROID_GetScreenKeyboardTextInput(buf, sizeof(buf));
	Cvar_ForceSet(editedCvar->name, buf);
	UI_TextEntryNodeValidateEdition(node);
	UI_RemoveFocus();
#endif
#endif
}