void InputNode::addChar(Uint16 code, SDLKey k)
	{
		Uint16 key = code;
		if ( k == SDLK_BACKSPACE )
		{
			_curr_index--;
			if ( _curr_index >= 0 )
				uni_slice(_str, 40, _curr_index);
			else
				_curr_index = 0;
		}
		else if ( k == SDLK_LEFT || k == SDLK_RIGHT || k == SDLK_UP || k == SDLK_DOWN )
		{
			int len = uni_length(_str);

			if ( k == SDLK_LEFT )
				_curr_index--;
			else if ( k == SDLK_RIGHT )
				_curr_index++;
			else if ( k == SDLK_UP )
				_curr_index = 0;
			else
				_curr_index = len;

			if ( _curr_index < 0 )
				_curr_index = 0;
			if ( _curr_index > len )
				_curr_index = len;
		}
		else if ( k == SDLK_RETURN )
		{
			onblur(); // this shouldn't be here, or is it okey? Should menu handle it?
			submit();
			return;
		}
		else if ( _curr_index < 39 && key != 0 )
		{
			// Insert the char into
			uni_place(_str, key, 40, _curr_index);
			_curr_index++;
		}

		renderText();
	}
예제 #2
0
void GUICONTROL::OnBlur() const
{
	onblur();
}