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:
이지한
2019-08-01 15:24:46 +09:00
parent de9043e223
commit 129b83e68f
13 changed files with 152 additions and 12 deletions

View File

@@ -85,6 +85,7 @@ namespace nana
virtual void mouse_dropfiles(graph_reference, const arg_dropfiles&);
virtual void focus(graph_reference, const arg_focus&);
virtual void key_ime(graph_reference, const arg_ime&);
virtual void key_press(graph_reference, const arg_keyboard&);
virtual void key_char(graph_reference, const arg_keyboard&);
virtual void key_release(graph_reference, const arg_keyboard&);
@@ -140,6 +141,7 @@ namespace nana
void resized(const arg_resized&, const bool);
void move(const arg_move&, const bool);
void focus(const arg_focus&, const bool);
void key_ime(const arg_ime& arg, const bool bForce__EmitInternal);
void key_press(const arg_keyboard&, const bool);
void key_char(const arg_keyboard&, const bool);
void key_release(const arg_keyboard&, const bool);

View File

@@ -34,6 +34,7 @@ namespace nana
unload, ///< A form is closed by clicking the X button, only works for root widget.
destroy, ///< A widget is about to be destroyed.
focus, ///< A widget's focus is changed.
key_ime,
key_press, ///< A keyboard is pressed on a focus widget.
key_char, ///< The focus widget received a character.
key_release, ///< A keyboard is released on a focus widget.

View File

@@ -466,6 +466,19 @@ namespace nana
reason focus_reason; ///< determines how the widget receives keyboard focus, it is ignored when 'getting' is equal to false
};
struct arg_ime: public event_arg
{
enum class reason
{
composition,
result
};
::nana::window window_handle; ///< A handle to the event window
reason ime_reason;
std::wstring composition_string;
};
struct arg_keyboard : public event_arg
{
event_code evt_code; ///< it is event_code::key_press in current event

View File

@@ -65,6 +65,7 @@ namespace nana
void mouse_up(graph_reference, const arg_mouse&) override;
void mouse_move(graph_reference, const arg_mouse&) override;
void mouse_wheel(graph_reference, const arg_wheel&) override;
void key_ime(graph_reference, const arg_ime&) override;
void key_press(graph_reference, const arg_keyboard&) override;
void key_char(graph_reference, const arg_keyboard&) override;
private:

View File

@@ -98,6 +98,7 @@ namespace nana{ namespace widgets
void set_accept(std::function<bool(char_type)>);
void set_accept(accepts);
bool respond_ime(const arg_ime& arg);
bool respond_char(const arg_keyboard& arg);
bool respond_key(const arg_keyboard& arg);
@@ -328,6 +329,8 @@ namespace nana{ namespace widgets
nana::upoint caret; //position of caret by text, it specifies the position of a new character
nana::upoint shift_begin_caret;
}points_;
size_t composition_size_ { 0 };
};
}//end namespace skeletons
}//end namespace widgets

View File

@@ -66,6 +66,7 @@ namespace nana
void mouse_move(graph_reference, const arg_mouse&) override;
void mouse_up(graph_reference, const arg_mouse& arg) override;
void mouse_leave(graph_reference, const arg_mouse&) override;
void key_ime(graph_reference, const arg_ime& arg) override;
void key_press(graph_reference, const arg_keyboard&) override;
void key_char(graph_reference, const arg_keyboard&) override;
void resized(graph_reference, const arg_resized&) override;

View File

@@ -83,6 +83,7 @@ namespace nana
void mouse_enter(graph_reference, const arg_mouse&) override;
void mouse_leave(graph_reference, const arg_mouse&) override;
void dbl_click(graph_reference, const arg_mouse&) override;
void key_ime(graph_reference, const arg_ime&) override;
void key_press(graph_reference, const arg_keyboard&)override;
void key_char(graph_reference, const arg_keyboard&) override;
void mouse_wheel(graph_reference, const arg_wheel&) override;