1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
---|
2 | <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/doc/charinput-qws.doc:36 -->
|
---|
3 | <html>
|
---|
4 | <head>
|
---|
5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
6 | <title>Character input in Qt/Embedded</title>
|
---|
7 | <style type="text/css"><!--
|
---|
8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
9 | a:link { color: #004faf; text-decoration: none }
|
---|
10 | a:visited { color: #672967; text-decoration: none }
|
---|
11 | body { background: #ffffff; color: black; }
|
---|
12 | --></style>
|
---|
13 | </head>
|
---|
14 | <body>
|
---|
15 |
|
---|
16 | <table border="0" cellpadding="0" cellspacing="0" width="100%">
|
---|
17 | <tr bgcolor="#E5E5E5">
|
---|
18 | <td valign=center>
|
---|
19 | <a href="index.html">
|
---|
20 | <font color="#004faf">Home</font></a>
|
---|
21 | | <a href="classes.html">
|
---|
22 | <font color="#004faf">All Classes</font></a>
|
---|
23 | | <a href="mainclasses.html">
|
---|
24 | <font color="#004faf">Main Classes</font></a>
|
---|
25 | | <a href="annotated.html">
|
---|
26 | <font color="#004faf">Annotated</font></a>
|
---|
27 | | <a href="groups.html">
|
---|
28 | <font color="#004faf">Grouped Classes</font></a>
|
---|
29 | | <a href="functions.html">
|
---|
30 | <font color="#004faf">Functions</font></a>
|
---|
31 | </td>
|
---|
32 | <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>Character input in Qt/Embedded</h1>
|
---|
33 |
|
---|
34 |
|
---|
35 |
|
---|
36 | <p> Internally in the client/server protocol, each key press and key
|
---|
37 | release is sent as a <tt>QWSKeyEvent</tt>. A QWSKeyEvent contains the
|
---|
38 | following fields:
|
---|
39 | <p> <center><table cellpadding="4" cellspacing="2" border="0">
|
---|
40 | <tr bgcolor="#f0f0f0"> <td valign="top"><tt>unicode</tt>
|
---|
41 | <td valign="top">Unicode value
|
---|
42 | <tr bgcolor="#d0d0d0"> <td valign="top"><tt>keycode</tt>
|
---|
43 | <td valign="top">Qt keycode value as defined in <a href="qnamespace-h.html">qnamespace.h</a>
|
---|
44 | <tr bgcolor="#f0f0f0"> <td valign="top"><tt>modifier</tt>
|
---|
45 | <td valign="top">A bitfield consisting of some of <a href="qt.html#ButtonState-enum">Qt::ShiftButton</a>,
|
---|
46 | <a href="qt.html#ButtonState-enum">Qt::ControlButton</a>, and <a href="qt.html#ButtonState-enum">Qt::AltButton</a>.
|
---|
47 | <tr bgcolor="#d0d0d0"> <td valign="top"><tt>is_press</tt>
|
---|
48 | <td valign="top">TRUE if this is a key press, FALSE if it is a key release.
|
---|
49 | <tr bgcolor="#f0f0f0"> <td valign="top"><tt>is_auto_repeat</tt>
|
---|
50 | <td valign="top">TRUE if this event is caused by auto repeat.
|
---|
51 | </table></center>
|
---|
52 | <p> When the server receives a key event it is sent to each client process
|
---|
53 | which is responsible for processing the key event and sending it to
|
---|
54 | the right window, if any. Key events may come from several different
|
---|
55 | sources.
|
---|
56 | <p> <h2> Keyboard drivers
|
---|
57 | </h2>
|
---|
58 | <a name="1"></a><p> A keyboard driver reads data from a device and gives key events to the
|
---|
59 | server.
|
---|
60 | <p> Keyboard drivers can be compiled into the library or loaded as
|
---|
61 | plugins. Running ./configure -help lists the available keyboard drivers.
|
---|
62 | The "tty" driver is enabled in the default configuration.
|
---|
63 | <p> The keyboard drivers all follow the same pattern. They read keyboard
|
---|
64 | data from a device, find out which keys were pressed, and then call
|
---|
65 | the static function QWSServer::processKeyEvent() with the key information.
|
---|
66 | <p> At present, the console keyboard driver also handles console switching
|
---|
67 | (<b>Ctrl+Alt-F1</b>...<b>Ctrl+Alt+F10</b>) and termination
|
---|
68 | (<b>Ctrl+Alt+Backspace</b>).
|
---|
69 | <p> To add a keyboard driver for a new device, subclasses of
|
---|
70 | <a href="qwskeyboardhandler.html">QWSKeyboardHandler</a> and <a href="qkbddriverplugin.html">QKbdDriverPlugin</a> can be
|
---|
71 | written and installed as plugins.
|
---|
72 | <p> <h2> Key event filters (input methods)
|
---|
73 | </h2>
|
---|
74 | <a name="2"></a><p> When the server receives a key event from a keyboard driver, it first
|
---|
75 | passes it through a filter.
|
---|
76 | <p> This can be used to implement input methods, providing input of
|
---|
77 | characters that are not on the keyboard.
|
---|
78 | <p> To make an input method, subclass QWSServer::KeyboardFilter (in <tt>src/kernel/qwindowsystem_qws.h</tt>) and implement the virtual function <tt>filter()</tt>. If <tt>filter()</tt> returns <tt>FALSE</tt>, the event will be sent to
|
---|
79 | the clients (using <a href="qwsserver.html#sendKeyEvent">QWSServer::sendKeyEvent</a>()). If <tt>filter()</tt> returns
|
---|
80 | <tt>TRUE</tt>, the event will be stopped. To generate new key events, use
|
---|
81 | QWSServer::sendKeyEvent(). (Do not use processKeyEvent(), since this
|
---|
82 | will lead to infinite recursion.)
|
---|
83 | <p> To install a keyboard event filter, use
|
---|
84 | <a href="qwsserver.html#setKeyboardFilter">QWSServer::setKeyboardFilter</a>(). Currently, only one filter
|
---|
85 | can be installed at a time.
|
---|
86 | <p> Filtering must be done in the server process.
|
---|
87 | <p> The launcher example contains an example of a simple input method,
|
---|
88 | <tt>SimpleIM</tt> which reads a substitution table from a file.
|
---|
89 | <p> <h2> Pen input
|
---|
90 | </h2>
|
---|
91 | <a name="3"></a><p> Key events do not need to come from a keyboard device. The server
|
---|
92 | process may call QWSServer::sendKeyEvent() at any time.
|
---|
93 | <p> Typically, this is done by popping up a widget, and letting the user
|
---|
94 | specify characters with the pointer device.
|
---|
95 | <p> <b>Note</b>: the key input widget should not take focus, since the
|
---|
96 | server would then just send the key events back to the input widget.
|
---|
97 | One way to make sure that the input widget never takes focus is to set
|
---|
98 | the <tt>WStyle_Customize</tt> and <tt>WStyle_Tool</tt> widget flags in
|
---|
99 | the <a href="qwidget.html">QWidget</a> constructor.
|
---|
100 | <p> The <a href="http://www.trolltech.com/products/qtopia/">Qtopia</a>
|
---|
101 | environment contains various input widgets such as
|
---|
102 | Handwriting Recognition and Virtual Keyboard.
|
---|
103 | <p>
|
---|
104 | <!-- eof -->
|
---|
105 | <p><address><hr><div align=center>
|
---|
106 | <table width=100% cellspacing=0 border=0><tr>
|
---|
107 | <td>Copyright © 2007
|
---|
108 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
109 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
110 | </table></div></address></body>
|
---|
111 | </html>
|
---|