Commit c4988bda authored by cutealien's avatar cutealien

EditBox works now with numpad on X11 (thx @Hendu for bureport).


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4926 dfc29bdd-3216-0410-991c-e03cc46cb475
parent f591a5ac
-------------------------- --------------------------
Changes in 1.9 (not yet released) Changes in 1.9 (not yet released)
- EditBox works now with numpad on X11
- Added helper functions for converting between wchar and utf-8. Patch provided by Hendu. - Added helper functions for converting between wchar and utf-8. Patch provided by Hendu.
- Added sphere frustum culling support. Patch provided by Hendu. - Added sphere frustum culling support. Patch provided by Hendu.
- Fixed issues with setViewPort method under OpenGL. (reported by anontypist) - Fixed issues with setViewPort method under OpenGL. (reported by anontypist)
......
...@@ -423,8 +423,9 @@ bool CGUIEditBox::processKey(const SEvent& event) ...@@ -423,8 +423,9 @@ bool CGUIEditBox::processKey(const SEvent& event)
return false; return false;
} }
} }
// default keyboard handling // Some special keys - but only handle them if KeyInput.Char is null as on some systems (X11) they might have same key-code as ansi-keys otherwise
else else if (event.KeyInput.Char == 0)
{
switch(event.KeyInput.Key) switch(event.KeyInput.Key)
{ {
case KEY_END: case KEY_END:
...@@ -479,17 +480,6 @@ bool CGUIEditBox::processKey(const SEvent& event) ...@@ -479,17 +480,6 @@ bool CGUIEditBox::processKey(const SEvent& event)
BlinkStartTime = os::Timer::getTime(); BlinkStartTime = os::Timer::getTime();
} }
break; break;
case KEY_RETURN:
if (MultiLine)
{
inputChar(L'\n');
}
else
{
calculateScrollPos();
sendGuiEvent( EGET_EDITBOX_ENTER );
}
return true;
case KEY_LEFT: case KEY_LEFT:
if (event.KeyInput.Shift) if (event.KeyInput.Shift)
...@@ -594,12 +584,17 @@ bool CGUIEditBox::processKey(const SEvent& event) ...@@ -594,12 +584,17 @@ bool CGUIEditBox::processKey(const SEvent& event)
return false; return false;
} }
break; break;
case KEY_INSERT:
if ( !isEnabled() )
break;
case KEY_BACK: OverwriteMode = !OverwriteMode;
break;
case KEY_DELETE:
if ( !isEnabled() ) if ( !isEnabled() )
break; break;
if (Text.size()) if (Text.size() != 0)
{ {
core::stringw s; core::stringw s;
...@@ -617,35 +612,47 @@ bool CGUIEditBox::processKey(const SEvent& event) ...@@ -617,35 +612,47 @@ bool CGUIEditBox::processKey(const SEvent& event)
} }
else else
{ {
// delete text behind cursor // delete text before cursor
if (CursorPos>0) s = Text.subString(0, CursorPos);
s = Text.subString(0, CursorPos-1); s.append( Text.subString(CursorPos+1, Text.size()-CursorPos-1) );
else
s = L"";
s.append( Text.subString(CursorPos, Text.size()-CursorPos) );
Text = s; Text = s;
--CursorPos;
} }
if (CursorPos < 0) if (CursorPos > (s32)Text.size())
CursorPos = 0; CursorPos = (s32)Text.size();
BlinkStartTime = os::Timer::getTime(); BlinkStartTime = os::Timer::getTime();
newMarkBegin = 0; newMarkBegin = 0;
newMarkEnd = 0; newMarkEnd = 0;
textChanged = true; textChanged = true;
} }
break; break;
case KEY_INSERT: default:
if ( !isEnabled() ) return false;
break; }
}
else
{
// default keyboard handling
switch(event.KeyInput.Key)
{
case KEY_RETURN:
if (MultiLine)
{
inputChar(L'\n');
}
else
{
calculateScrollPos();
sendGuiEvent( EGET_EDITBOX_ENTER );
}
return true;
OverwriteMode = !OverwriteMode; case KEY_BACK:
break;
case KEY_DELETE:
if ( !isEnabled() ) if ( !isEnabled() )
break; break;
if (Text.size() != 0) if (Text.size())
{ {
core::stringw s; core::stringw s;
...@@ -663,15 +670,18 @@ bool CGUIEditBox::processKey(const SEvent& event) ...@@ -663,15 +670,18 @@ bool CGUIEditBox::processKey(const SEvent& event)
} }
else else
{ {
// delete text before cursor // delete text behind cursor
s = Text.subString(0, CursorPos); if (CursorPos>0)
s.append( Text.subString(CursorPos+1, Text.size()-CursorPos-1) ); s = Text.subString(0, CursorPos-1);
else
s = L"";
s.append( Text.subString(CursorPos, Text.size()-CursorPos) );
Text = s; Text = s;
--CursorPos;
} }
if (CursorPos > (s32)Text.size()) if (CursorPos < 0)
CursorPos = (s32)Text.size(); CursorPos = 0;
BlinkStartTime = os::Timer::getTime(); BlinkStartTime = os::Timer::getTime();
newMarkBegin = 0; newMarkBegin = 0;
newMarkEnd = 0; newMarkEnd = 0;
...@@ -713,6 +723,7 @@ bool CGUIEditBox::processKey(const SEvent& event) ...@@ -713,6 +723,7 @@ bool CGUIEditBox::processKey(const SEvent& event)
inputChar(event.KeyInput.Char); inputChar(event.KeyInput.Char);
return true; return true;
} }
}
// Set new text markers // Set new text markers
setTextMarkers( newMarkBegin, newMarkEnd ); setTextMarkers( newMarkBegin, newMarkEnd );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment