From 55e687e80d5c7c94c830cad14a3c0c02729d2a82 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Thu, 12 Nov 2015 16:01:57 +0200 Subject: [PATCH 1/2] Fixed displaying utf8 string on alt attr. --HG-- branch : develop --- code/nel/src/gui/group_html.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index 42d237815..4df0b0ee5 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -3621,7 +3621,7 @@ namespace NLGUI } else { - ctrlButton->setDefaultContextHelp(ucstring(tooltip)); + ctrlButton->setDefaultContextHelp(ucstring::makeFromUtf8(tooltip)); //ctrlButton->setOnContextHelp(string(tooltip)); } From 76ee797e493d7fad9d2dc58a2fe6c38309c907a9 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Thu, 12 Nov 2015 20:15:04 +0200 Subject: [PATCH 2/2] Add lua function CCtrlBase::setTooltipUtf8 to set tooltip from html page --HG-- branch : develop --- code/nel/include/nel/gui/ctrl_base.h | 4 ++++ code/nel/src/gui/ctrl_base.cpp | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/code/nel/include/nel/gui/ctrl_base.h b/code/nel/include/nel/gui/ctrl_base.h index 3b522e114..35148b5b0 100644 --- a/code/nel/include/nel/gui/ctrl_base.h +++ b/code/nel/include/nel/gui/ctrl_base.h @@ -151,8 +151,12 @@ namespace NLGUI // called when keyboard capture has been lost virtual void onKeyboardCaptureLost() {} + // 'tooltip' property expects string to be ucstring or latin1 which is not possible from html page + int luaSetTooltipUtf8(CLuaState &ls); + REFLECT_EXPORT_START(CCtrlBase, CViewBase) REFLECT_UCSTRING("tooltip", getDefaultContextHelp, setDefaultContextHelp); + REFLECT_LUA_METHOD("setTooltipUtf8", luaSetTooltipUtf8); REFLECT_EXPORT_END // special for mouse over : return true and fill the name of the cursor to display diff --git a/code/nel/src/gui/ctrl_base.cpp b/code/nel/src/gui/ctrl_base.cpp index 5c250a0da..475761e89 100644 --- a/code/nel/src/gui/ctrl_base.cpp +++ b/code/nel/src/gui/ctrl_base.cpp @@ -19,6 +19,7 @@ #include "libxml/globals.h" #include "nel/misc/debug.h" #include "nel/misc/xml_auto_ptr.h" +#include "nel/gui/lua_ihm.h" #include "nel/gui/ctrl_base.h" #include "nel/gui/interface_group.h" #include "nel/gui/widget_manager.h" @@ -556,5 +557,17 @@ namespace NLGUI return itr2->second; } + // *************************************************************************** + int CCtrlBase::luaSetTooltipUtf8(CLuaState &ls) + { + const char *funcName = "setTooltipUtf8"; + CLuaIHM::checkArgCount(ls, funcName, 1); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); + std::string tooltip = ls.toString(1); + + setDefaultContextHelp(ucstring::makeFromUtf8(tooltip)); + + return 0; + } }