mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
parent
8b111ab6c3
commit
f627a72ebb
|
@ -49,7 +49,7 @@ CInput::CInput()
|
|||
m_VideoRestartNeeded = 0;
|
||||
m_pClipboardText = NULL;
|
||||
|
||||
m_IsEditingText = false;
|
||||
m_CountEditingText = 0;
|
||||
}
|
||||
|
||||
void CInput::Init()
|
||||
|
@ -143,18 +143,25 @@ void CInput::NextFrame()
|
|||
|
||||
bool CInput::GetIMEState()
|
||||
{
|
||||
return m_IsEditingText;
|
||||
return m_CountEditingText > 0;
|
||||
}
|
||||
|
||||
void CInput::SetIMEState(bool activate)
|
||||
void CInput::SetIMEState(bool Activate)
|
||||
{
|
||||
if (activate)
|
||||
SDL_StartTextInput();
|
||||
if(Activate)
|
||||
{
|
||||
if(m_CountEditingText == 0)
|
||||
SDL_StartTextInput();
|
||||
else
|
||||
m_CountEditingText++;
|
||||
}
|
||||
else
|
||||
{
|
||||
// force stop editing
|
||||
SDL_StopTextInput();
|
||||
m_IsEditingText = false;
|
||||
if(m_CountEditingText == 0)
|
||||
return;
|
||||
m_CountEditingText--;
|
||||
if(m_CountEditingText == 0)
|
||||
SDL_StopTextInput();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -196,20 +203,17 @@ int CInput::Update()
|
|||
int Key = -1;
|
||||
int Scancode = 0;
|
||||
int Action = IInput::FLAG_PRESS;
|
||||
switch (Event.type)
|
||||
switch(Event.type)
|
||||
{
|
||||
case SDL_TEXTEDITING:
|
||||
{
|
||||
if (str_length(Event.edit.text))
|
||||
if(str_length(Event.edit.text))
|
||||
{
|
||||
str_format(m_pEditingText, sizeof(m_pEditingText), Event.edit.text);
|
||||
m_EditingCursor = 0;
|
||||
for (int i = 0; i < Event.edit.start; i++)
|
||||
m_EditingCursor = str_utf8_forward(m_pEditingText, m_EditingCursor);
|
||||
m_IsEditingText = true;
|
||||
}
|
||||
else
|
||||
m_IsEditingText = false;
|
||||
break;
|
||||
}
|
||||
case SDL_TEXTINPUT:
|
||||
|
@ -318,7 +322,7 @@ int CInput::Update()
|
|||
return 1;
|
||||
}
|
||||
|
||||
if(Key >= 0 && Key < g_MaxKeys && !IgnoreKeys && !m_IsEditingText)
|
||||
if(Key >= 0 && Key < g_MaxKeys && !IgnoreKeys && m_CountEditingText == 0)
|
||||
{
|
||||
if(Action&IInput::FLAG_PRESS)
|
||||
{
|
||||
|
|
|
@ -26,7 +26,7 @@ class CInput : public IEngineInput
|
|||
int m_InputCounter;
|
||||
|
||||
//ime support
|
||||
bool m_IsEditingText;
|
||||
int m_CountEditingText;
|
||||
char m_pEditingText[32];
|
||||
int m_EditingCursor;
|
||||
|
||||
|
@ -55,7 +55,7 @@ public:
|
|||
virtual int VideoRestartNeeded();
|
||||
|
||||
virtual bool GetIMEState();
|
||||
virtual void SetIMEState(bool activate);
|
||||
virtual void SetIMEState(bool Activate);
|
||||
virtual const char* GetIMECandidate();
|
||||
virtual int GetEditingCursor();
|
||||
};
|
||||
|
|
|
@ -69,7 +69,7 @@ public:
|
|||
virtual void MouseRelative(float *x, float *y) = 0;
|
||||
|
||||
virtual bool GetIMEState() = 0;
|
||||
virtual void SetIMEState(bool activate) = 0;
|
||||
virtual void SetIMEState(bool Activate) = 0;
|
||||
virtual const char* GetIMECandidate() = 0;
|
||||
virtual int GetEditingCursor() = 0;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue