From bcd6c84a66280c5eeed363c91638deeecbcb91f1 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Mon, 9 Apr 2012 01:42:44 +0000 Subject: [PATCH] bugfix [#30760] edit text property bug backspace was messing up with utf8 text. hijacking Blender utf8 functions tested in CMake but I think scons should work too. No idea about pure 'make' Happy Easter ;) --- source/gameengine/GameLogic/CMakeLists.txt | 1 + source/gameengine/GameLogic/SCA_KeyboardSensor.cpp | 10 +++++++++- source/gameengine/GameLogic/SConscript | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/source/gameengine/GameLogic/CMakeLists.txt b/source/gameengine/GameLogic/CMakeLists.txt index 98255bb8b97..64f198f72a0 100644 --- a/source/gameengine/GameLogic/CMakeLists.txt +++ b/source/gameengine/GameLogic/CMakeLists.txt @@ -28,6 +28,7 @@ set(INC ../Expressions ../Rasterizer ../SceneGraph + ../../blender/blenlib ../../../intern/container ../../../intern/moto/include ../../../intern/string diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp index 48237a1b467..704b244c52c 100644 --- a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp +++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp @@ -39,6 +39,10 @@ #include "StringValue.h" #include "SCA_IInputDevice.h" +extern "C" { + #include "BLI_string_cursor_utf8.h" +} + /* ------------------------------------------------------------------------- */ /* Native functions */ /* ------------------------------------------------------------------------- */ @@ -338,7 +342,11 @@ void SCA_KeyboardSensor::AddToTargetProp(int keyIndex) STR_String newprop = tprop->GetText(); int oldlength = newprop.Length(); if (oldlength >= 1 ) { - newprop.SetLength(oldlength - 1); + int newlength=oldlength; + + BLI_str_cursor_step_prev_utf8(newprop, NULL, &newlength); + newprop.SetLength(newlength); + CStringValue * newstringprop = new CStringValue(newprop, m_targetprop); GetParent()->SetProperty(m_targetprop, newstringprop); newstringprop->Release(); diff --git a/source/gameengine/GameLogic/SConscript b/source/gameengine/GameLogic/SConscript index 62bdbc29544..e01222e81d7 100644 --- a/source/gameengine/GameLogic/SConscript +++ b/source/gameengine/GameLogic/SConscript @@ -6,6 +6,7 @@ sources = env.Glob('*.cpp') + env.Glob('Joystick/*.cpp') incs = '. #/intern/string #intern/container' incs += ' #/source/gameengine/Expressions #/intern/moto/include' incs += ' #/source/gameengine/Rasterizer #/source/gameengine/SceneGraph' +incs += ' #/blender/blenlib' defs = []