From 31b7efe8e9246bd7bc2eea2b08682195268fecf0 Mon Sep 17 00:00:00 2001 From: handa Date: Fri, 16 Sep 2005 11:51:20 +0000 Subject: [PATCH] (ButtonProc): Don't reset ic, instead send Minput_focus_move event to the current input method. (FocusInProc, FocusOutProc): New functions. (actions): Add elements for FocusIn and FocusOut. (main): Add elements for FocusIn and FocusOut to trans2. --- example/medit.c | 50 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/example/medit.c b/example/medit.c index cf7aa7c..ea60f2e 100644 --- a/example/medit.c +++ b/example/medit.c @@ -1252,12 +1252,12 @@ ButtonProc (Widget w, XEvent *event, String *str, Cardinal *num) redraw (sel_start.y0, sel_end.y1, 1, 0); } hide_cursor (); - if (current_input_context) + if (current_input_context + && minput_filter (current_input_context, Minput_focus_move, NULL) == 0) { MText *produced = mtext (); - minput_reset_ic (current_input_context); - minput_lookup (current_input_context, Mnil, NULL, produced); + minput_lookup (current_input_context, Mnil, NULL, produced); if (mtext_len (produced) > 0) { insert_chars (produced); @@ -1410,6 +1410,42 @@ ButtonMoveProc (Widget w, XEvent *event, String *str, Cardinal *num) } void +FocusInProc (Widget w, XEvent *event, String *str, Cardinal *num) +{ + if (current_input_context + && minput_filter (current_input_context, Minput_focus_out, NULL) == 0) + { + MText *produced = mtext (); + + minput_lookup (current_input_context, Mnil, NULL, produced); + if (mtext_len (produced) > 0) + { + hide_cursor (); + insert_chars (produced); + } + m17n_object_unref (produced); + } +} + +void +FocusOutProc (Widget w, XEvent *event, String *str, Cardinal *num) +{ + if (current_input_context + && minput_filter (current_input_context, Minput_focus_out, NULL) == 0) + { + MText *produced = mtext (); + + minput_lookup (current_input_context, Mnil, NULL, produced); + if (mtext_len (produced) > 0) + { + hide_cursor (); + insert_chars (produced); + } + m17n_object_unref (produced); + } +} + +void ScrollProc (Widget w, XtPointer client_data, XtPointer position) { int from; @@ -2457,7 +2493,9 @@ XtActionsRec actions[] = { {"ButtonRelease", ButtonReleaseProc}, {"ButtonMotion", ButtonMoveProc}, {"Button2Press", Button2Proc}, - {"MenuHelp", MenuHelpProc} + {"MenuHelp", MenuHelpProc}, + {"FocusIn", FocusInProc}, + {"FocusOut", FocusOutProc} }; @@ -2507,7 +2545,9 @@ main (int argc, char **argv) : Button2Press()"; /* Translation table for the top form widget. */ String trans2 = ": Key()\n\ - : Key()"; + : Key()\n\ + : FocusIn()\n\ + : FocusOut()"; String pop_face_trans = ": MenuHelp(Pop face property) highlight()\n\ : MenuHelp() reset()\n\ -- 1.7.10.4