Commit b1a41dab authored by cutealien's avatar cutealien

Last fix to enable numkeys on X11 had broken the normal DELETE key on X11. So...

Last fix to enable numkeys on X11 had broken the normal DELETE key on X11. So reworked the fix some more. Not yet tested on Windows (but should work as well in theory).


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4943 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 38fd0036
...@@ -594,33 +594,8 @@ bool CGUIEditBox::processKey(const SEvent& event) ...@@ -594,33 +594,8 @@ bool CGUIEditBox::processKey(const SEvent& event)
if ( !isEnabled() ) if ( !isEnabled() )
break; break;
if (Text.size() != 0) if (keyDelete())
{ {
core::stringw s;
if (MarkBegin != MarkEnd)
{
// delete marked text
const s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd;
const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin;
s = Text.subString(0, realmbgn);
s.append( Text.subString(realmend, Text.size()-realmend) );
Text = s;
CursorPos = realmbgn;
}
else
{
// delete text before cursor
s = Text.subString(0, CursorPos);
s.append( Text.subString(CursorPos+1, Text.size()-CursorPos-1) );
Text = s;
}
if (CursorPos > (s32)Text.size())
CursorPos = (s32)Text.size();
BlinkStartTime = os::Timer::getTime(); BlinkStartTime = os::Timer::getTime();
newMarkBegin = 0; newMarkBegin = 0;
newMarkEnd = 0; newMarkEnd = 0;
...@@ -689,6 +664,31 @@ bool CGUIEditBox::processKey(const SEvent& event) ...@@ -689,6 +664,31 @@ bool CGUIEditBox::processKey(const SEvent& event)
} }
break; break;
case KEY_DELETE:
// At least on X11 we get a char with 127 when the delete key is pressed.
// We get no char when the delete key on numkeys is pressed with numlock off (handled in the other case calling keyDelete as Char is then 0).
// We get a keykode != 127 when delete key on numlock is pressed with numlock on.
if (event.KeyInput.Char == 127)
{
if ( !isEnabled() )
break;
if (keyDelete())
{
BlinkStartTime = os::Timer::getTime();
newMarkBegin = 0;
newMarkEnd = 0;
textChanged = true;
}
break;
}
else
{
inputChar(event.KeyInput.Char);
return true;
}
case KEY_ESCAPE: case KEY_ESCAPE:
case KEY_TAB: case KEY_TAB:
case KEY_SHIFT: case KEY_SHIFT:
...@@ -743,6 +743,40 @@ bool CGUIEditBox::processKey(const SEvent& event) ...@@ -743,6 +743,40 @@ bool CGUIEditBox::processKey(const SEvent& event)
return true; return true;
} }
bool CGUIEditBox::keyDelete()
{
if (Text.size() != 0)
{
core::stringw s;
if (MarkBegin != MarkEnd)
{
// delete marked text
const s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd;
const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin;
s = Text.subString(0, realmbgn);
s.append( Text.subString(realmend, Text.size()-realmend) );
Text = s;
CursorPos = realmbgn;
}
else
{
// delete text before cursor
s = Text.subString(0, CursorPos);
s.append( Text.subString(CursorPos+1, Text.size()-CursorPos-1) );
Text = s;
}
if (CursorPos > (s32)Text.size())
CursorPos = (s32)Text.size();
return true;
}
return false;
}
//! draws the element and its children //! draws the element and its children
void CGUIEditBox::draw() void CGUIEditBox::draw()
......
...@@ -162,6 +162,8 @@ namespace gui ...@@ -162,6 +162,8 @@ namespace gui
void sendGuiEvent(EGUI_EVENT_TYPE type); void sendGuiEvent(EGUI_EVENT_TYPE type);
//! set text markers //! set text markers
void setTextMarkers(s32 begin, s32 end); void setTextMarkers(s32 begin, s32 end);
//! delete current selection or next char
bool keyDelete();
bool processKey(const SEvent& event); bool processKey(const SEvent& event);
bool processMouse(const SEvent& event); bool processMouse(const SEvent& event);
......
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