Back to index

im-sdk  12.3.91
sendkey2.c
Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include <stdlib.h>
00003 #include <iiimcf.h>
00004 #include <time.h>
00005 #include "common.h"
00006 
00007 IIIMCF_context context;
00008 
00009 static IIIMF_status
00010 preedit_handler(
00011     IIIMCF_context c,
00012     IIIMCF_event event,
00013     IIIMCF_component current,
00014     IIIMCF_component parent
00015 )
00016 {
00017     test_show_preedit_info(c);
00018     return IIIMF_STATUS_SUCCESS;
00019 }
00020 
00021 static IIIMF_status
00022 keyevent_handler(
00023     IIIMCF_context c,
00024     IIIMCF_event event,
00025     IIIMCF_component current,
00026     IIIMCF_component parent
00027 )
00028 {
00029     IIIMCF_event_type et;
00030     IIIMCF_keyevent kev;
00031 
00032     check(iiimcf_get_event_type(event, &et));
00033     if (et == IIIMCF_EVENT_TYPE_KEYEVENT) {
00034        check(iiimcf_get_keyevent_value(event, &kev));
00035        fprintf(stderr, "Keyevent[%d]:(%d, %d, %d, %d)\n",
00036               et, kev.keycode, kev.keychar, kev.modifier, kev.time_stamp);
00037     }
00038 
00039     return IIIMF_STATUS_SUCCESS;
00040 }
00041 
00042 static void
00043 create_context()
00044 {
00045     check(iiimcf_create_context(handle, IIIMCF_ATTR_NULL, &context));
00046 }
00047 
00048 static void
00049 destroy_context(
00050     IIIMCF_context c
00051 )
00052 {
00053     check(iiimcf_destroy_context(c));
00054 }
00055 
00056 static void
00057 register_components()
00058 {
00059     IIIMCF_component parent, comp;
00060 
00061     check(iiimcf_get_component(handle,
00062                             "org.OpenI18N.IIIMCF.UI.preedit",
00063                             &parent));
00064     check(iiimcf_register_component(handle,
00065                                 "org.OpenI18N.IIIMCF.test.preedit",
00066                                 preedit_handler,
00067                                 parent,
00068                                 &comp));
00069     check(iiimcf_get_component(handle,
00070                             "org.OpenI18N.IIIMCF.event.key",
00071                             &parent));
00072     check(iiimcf_register_component(handle,
00073                                 "org.OpenI18N.IIIMCF.test.event.key",
00074                                 keyevent_handler,
00075                                 parent,
00076                                 &comp));
00077 }
00078 
00079 int
00080 main(
00081     int argc,
00082     char **argv
00083 )
00084 {
00085     test_init();
00086     register_components();
00087     create_context();
00088 
00089     test_forwardkey(context, IIIMF_KEYCODE_A, 'a', 0);
00090     test_show_incoming_events(context, 1);
00091     test_trigger(context, 1);
00092     test_show_incoming_events(context, 1);
00093     test_forwardkey(context, IIIMF_KEYCODE_K, 'k', 0);
00094     test_show_incoming_events(context, 1);
00095     test_forwardkey(context, IIIMF_KEYCODE_U, 'u', 0);
00096     test_show_incoming_events(context, 1);
00097     test_forwardkey(context, IIIMF_KEYCODE_1, '1', 0);
00098     test_show_incoming_events(context, 1);
00099     test_forwardkey(context, IIIMF_KEYCODE_ENTER, 0, 0);
00100     test_show_incoming_events(context, 1);
00101     test_trigger(context, 0);
00102     test_show_incoming_events(context, 1);
00103 
00104     destroy_context(context);
00105     test_uninit();
00106 
00107     return 0;
00108 }
00109 
00110 /* Local Variables: */
00111 /* c-file-style: "iiim-project" */
00112 /* End: */
00113