Пример #1
0
// Handles a key press
bool CLTGUIEditCtrl::HandleChar(wchar_t c)
{
    if (CLTGUICtrl::HandleChar(c)) return true;
    if (c < ' ') return false;

	if (m_pFn)
	{
		c = (*m_pFn)(c,m_nCaretPos);
		if (!c)
			return LTFALSE;
	}

	switch	(m_eInputMode)
	{
	case kInputAlphaNumeric:
		if (!isalnum(c)) return false;
		break;
	case kInputAlphaOnly:
		if (!isalpha(c)) return false;
		break;
	case kInputNumberOnly:
		if (!isdigit(c)) return false;
		break;
	case kInputFileFriendly:
		if (!IsFileFriendly(c,(m_nCaretPos == 0))) return false;
		break;
	};


	AddCharacter(c);
    return true;
}
Пример #2
0
// Handles a key press
LTBOOL CLTGUIEditCtrl::HandleChar(unsigned char c)
{
    if (CLTGUICtrl::HandleChar(c)) return LTTRUE;
    if (c < ' ') return LTFALSE;

	switch	(m_eInputMode)
	{
	case kInputAlphaNumeric:
		if (!isalnum(c)) return LTFALSE;
		break;
	case kInputAlphaOnly:
		if (!isalpha(c)) return LTFALSE;
		break;
	case kInputNumberOnly:
		if (!isdigit(c)) return LTFALSE;
		break;
	case kInputFileFriendly:
		if (!IsFileFriendly(c,(m_nCaretPos == 0))) return LTFALSE;
		break;

	// Special case disallowing % and \ from a string. Used so the entire codebase doesn't need to be changed
	// for playernames and teams 
	case kInputSprintfFriendly:
		if ( c == 37 || c == 92 )
			  return LTFALSE;
		break;

	};


	AddCharacter(c);
    return LTTRUE;
}