This has never worked before in IRRlicht, but last week I tried something and would like to propose this for a patch. (Unless you think there is a better method to implement support for this)
I modified the source file named "CGUIEditBox.cpp"
and changed the method inputchar with this:
Code: Select all
void CGUIEditBox::inputChar(wchar_t c)
{
static bool accentmod = false;
static bool accentmod1 = false;
static bool accentmod2 = false;
static bool accentmod3 = false;
if (!IsEnabled)
return;
if (c != 0)
{
if (Text.size() < Max || Max == 0)
{
core::stringw s;
if (MarkBegin != MarkEnd)
{
// replace marked text
const s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd;
const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin;
if (c==*L"`") accentmod=true;
if (c==168) accentmod1=true; // ¨ badly detected, quick fix
if (c==*L"^") accentmod2=true;
if (c==184) accentmod3=true; // ¸ badly detected, quick fix
s = Text.subString(0, realmbgn);
if (!accentmod && !accentmod1 && !accentmod2 && !accentmod3)
{
s.append(c);
CursorPos = realmbgn+1;
} else CursorPos = realmbgn;
s.append( Text.subString(realmend, Text.size()-realmend) );
Text = s;
}
else
{
// add new character
// Christian Clavet, check here for the accent key.
if (accentmod)
{
if (c==*L"a") c=*L"à";
if (c==*L"A") c=*L"À";
if (c==*L"e") c=*L"è";
if (c==*L"E") c=*L"È";
if (c==*L"i") c=*L"ì";
if (c==*L"I") c=*L"Ì";
if (c==*L"o") c=*L"ò";
if (c==*L"O") c=*L"Ò";
if (c==*L"u") c=*L"ù";
if (c==*L"U") c=*L"Ù";
accentmod=false;
} else
if (accentmod1)
{
if (c==*L"a") c=*L"ä";
if (c==*L"A") c=*L"Ä";
if (c==*L"e") c=*L"ë";
if (c==*L"E") c=*L"Ë";
if (c==*L"i") c=*L"ï";
if (c==*L"I") c=*L"Ï";
if (c==*L"o") c=*L"ö";
if (c==*L"O") c=*L"Ö";
if (c==*L"u") c=*L"ü";
if (c==*L"U") c=*L"Ü";
accentmod1=false;
} else
if (accentmod2)
{
if (c==*L"a") c=*L"â";
if (c==*L"A") c=*L"Â";
if (c==*L"e") c=*L"ê";
if (c==*L"E") c=*L"Ê";
if (c==*L"i") c=*L"î";
if (c==*L"I") c=*L"Î";
if (c==*L"o") c=*L"ô";
if (c==*L"O") c=*L"Ô";
if (c==*L"u") c=*L"û";
if (c==*L"U") c=*L"Û";
accentmod2=false;
} else
if (accentmod3)
{
if (c==*L"c") c=*L"ç";
if (c==*L"C") c=*L"Ç";
accentmod3=false;
}
if (c==*L"`") accentmod=true;
if (c==168) accentmod1=true; // ¨ badly detected, quick fix
if (c==*L"^") accentmod2=true;
if (c==184) accentmod3=true; // ¸ badly detected, quick fix
if (!accentmod && !accentmod1 && !accentmod2 && !accentmod3)
{
s = Text.subString(0, CursorPos);
s.append(c);
s.append( Text.subString(CursorPos, Text.size()-CursorPos) );
Text = s;
++CursorPos;
}
}
BlinkStartTime = os::Timer::getTime();
setTextMarkers(0, 0);
}
}
breakText();
sendGuiEvent(EGET_EDITBOX_CHANGED);
calculateScrollPos();
}
Code: Select all
Index: CGUIEditBox.cpp
===================================================================
--- CGUIEditBox.cpp (revision 2900)
+++ CGUIEditBox.cpp (working copy)
@@ -1255,9 +1255,13 @@
return (s32)BrokenTextPositions.size() - 1;
}
-
void CGUIEditBox::inputChar(wchar_t c)
{
+ static bool accentmod = false;
+ static bool accentmod1 = false;
+ static bool accentmod2 = false;
+ static bool accentmod3 = false;
+
if (!IsEnabled)
return;
@@ -1266,27 +1270,95 @@
if (Text.size() < Max || Max == 0)
{
core::stringw s;
-
+
if (MarkBegin != MarkEnd)
{
// replace marked text
const s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd;
const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin;
+ if (c==*L"`") accentmod=true;
+ if (c==168) accentmod1=true; // ¨ badly detected, quick fix
+ if (c==*L"^") accentmod2=true;
+ if (c==184) accentmod3=true; // ¸ badly detected, quick fix
s = Text.subString(0, realmbgn);
- s.append(c);
+ if (!accentmod && !accentmod1 && !accentmod2 && !accentmod3)
+ {
+ s.append(c);
+ CursorPos = realmbgn+1;
+ } else CursorPos = realmbgn;
s.append( Text.subString(realmend, Text.size()-realmend) );
+
Text = s;
- CursorPos = realmbgn+1;
+
}
else
{
// add new character
- s = Text.subString(0, CursorPos);
- s.append(c);
- s.append( Text.subString(CursorPos, Text.size()-CursorPos) );
- Text = s;
- ++CursorPos;
+ // support for accent key method.
+ if (accentmod)
+ {
+ if (c==*L"a") c=*L"à";
+ if (c==*L"A") c=*L"À";
+ if (c==*L"e") c=*L"è";
+ if (c==*L"E") c=*L"È";
+ if (c==*L"i") c=*L"ì";
+ if (c==*L"I") c=*L"Ì";
+ if (c==*L"o") c=*L"ò";
+ if (c==*L"O") c=*L"Ò";
+ if (c==*L"u") c=*L"ù";
+ if (c==*L"U") c=*L"Ù";
+ accentmod=false;
+
+ } else
+ if (accentmod1)
+ {
+ if (c==*L"a") c=*L"ä";
+ if (c==*L"A") c=*L"Ä";
+ if (c==*L"e") c=*L"ë";
+ if (c==*L"E") c=*L"Ë";
+ if (c==*L"i") c=*L"ï";
+ if (c==*L"I") c=*L"Ï";
+ if (c==*L"o") c=*L"ö";
+ if (c==*L"O") c=*L"Ö";
+ if (c==*L"u") c=*L"ü";
+ if (c==*L"U") c=*L"Ü";
+ accentmod1=false;
+
+ } else
+ if (accentmod2)
+ {
+ if (c==*L"a") c=*L"â";
+ if (c==*L"A") c=*L"Â";
+ if (c==*L"e") c=*L"ê";
+ if (c==*L"E") c=*L"Ê";
+ if (c==*L"i") c=*L"î";
+ if (c==*L"I") c=*L"Î";
+ if (c==*L"o") c=*L"ô";
+ if (c==*L"O") c=*L"Ô";
+ if (c==*L"u") c=*L"û";
+ if (c==*L"U") c=*L"Û";
+ accentmod2=false;
+
+ } else
+ if (accentmod3)
+ {
+ if (c==*L"c") c=*L"ç";
+ if (c==*L"C") c=*L"Ç";
+ accentmod3=false;
+ }
+ if (c==*L"`") accentmod=true;
+ if (c==168) accentmod1=true; // ¨ badly detected, quick fix
+ if (c==*L"^") accentmod2=true;
+ if (c==184) accentmod3=true; // ¸ badly detected, quick fix
+ if (!accentmod && !accentmod1 && !accentmod2 && !accentmod3)
+ {
+ s = Text.subString(0, CursorPos);
+ s.append(c);
+ s.append( Text.subString(CursorPos, Text.size()-CursorPos) );
+ Text = s;
+ ++CursorPos;
+ }
}
BlinkStartTime = os::Timer::getTime();
@@ -1298,7 +1370,6 @@
calculateScrollPos();
}
-
void CGUIEditBox::calculateScrollPos()
{
if (!AutoScroll)