fix the strange behavior of Korean ime composition window.
Because Hangul is a combination character, WM_IME_STARTCOMPOSITION is only called once when the IME input is started, so the position of the composition window is strange. Therefore, I solved the problem by controlling the state of characters combined using WM_IME_COMPOSITION and WM_IME_CHAR. We have also improved to support other IME languages such as Chinese and Japanese.
This commit is contained in:
@@ -773,6 +773,13 @@ namespace nana
|
||||
API::dev::lazy_refresh();
|
||||
}
|
||||
|
||||
void trigger::key_ime(graph_reference, const arg_ime& arg)
|
||||
{
|
||||
drawer_->editor()->respond_ime(arg);
|
||||
if (drawer_->editor()->try_refresh())
|
||||
API::dev::lazy_refresh();
|
||||
}
|
||||
|
||||
void trigger::key_char(graph_reference, const arg_keyboard& arg)
|
||||
{
|
||||
drawer_->editor()->respond_char(arg);
|
||||
|
||||
@@ -1163,6 +1163,43 @@ namespace nana {
|
||||
impl_->capacities.acceptive = acceptive;
|
||||
}
|
||||
|
||||
bool text_editor::respond_ime(const arg_ime& arg)
|
||||
{
|
||||
if (!API::window_enabled(window_))
|
||||
return false;
|
||||
|
||||
if (select_.a != select_.b)
|
||||
{
|
||||
points_.caret = _m_erase_select(false);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < composition_size_; ++i)
|
||||
{
|
||||
backspace(false, false);
|
||||
}
|
||||
|
||||
if (arg.ime_reason == arg_ime::reason::composition)
|
||||
{
|
||||
composition_size_ = arg.composition_string.length();
|
||||
points_.caret = _m_put(std::move(arg.composition_string), false);
|
||||
|
||||
_m_reset_content_size(true);
|
||||
textbase().text_changed();
|
||||
|
||||
if (this->_m_adjust_view())
|
||||
impl_->cview->sync(false);
|
||||
|
||||
reset_caret();
|
||||
impl_->try_refresh = sync_graph::refresh;
|
||||
}
|
||||
else
|
||||
{
|
||||
composition_size_ = 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool text_editor::respond_char(const arg_keyboard& arg) //key is a character of ASCII code
|
||||
{
|
||||
if (!API::window_enabled(window_))
|
||||
|
||||
@@ -621,6 +621,13 @@ namespace nana
|
||||
API::dev::lazy_refresh();
|
||||
}
|
||||
|
||||
void drawer::key_ime(graph_reference, const arg_ime& arg)
|
||||
{
|
||||
impl_->editor()->respond_ime(arg);
|
||||
if (impl_->editor()->try_refresh())
|
||||
API::dev::lazy_refresh();
|
||||
}
|
||||
|
||||
void drawer::key_press(graph_reference, const arg_keyboard& arg)
|
||||
{
|
||||
if (impl_->editor()->respond_key(arg))
|
||||
|
||||
@@ -152,6 +152,13 @@ namespace drawerbase {
|
||||
API::dev::lazy_refresh();
|
||||
}
|
||||
|
||||
void drawer::key_ime(graph_reference, const arg_ime& arg)
|
||||
{
|
||||
editor_->respond_ime(arg);
|
||||
if (editor_->try_refresh())
|
||||
API::dev::lazy_refresh();
|
||||
}
|
||||
|
||||
void drawer::key_press(graph_reference, const arg_keyboard& arg)
|
||||
{
|
||||
editor_->respond_key(arg);
|
||||
|
||||
Reference in New Issue
Block a user