<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE TIP SYSTEM "http://tcl.activestate.com/cgi-bin/tct/tip/tipxml.dtd">
<!-- Converted at Thu Feb 09 12:09:47 GMT 2012 -->
<!-- TIP AutoGenerator - written by Donal K. Fellows -->

<TIP number='96'>
<header><title>Add [tk caret] Command and Tk_SetCaretPos API</title><author address="mailto:JeffH@ActiveState.com">Jeff Hobbs</author><status type='project' state='final' tclversion="8.4" vote='after'>$Revision: 1.4 $</status><history></history><created day='29' month='may' year='2002' /></header>
<abstract>This TIP proposes to add a [tk caret] command and [Tk_SetCaretPos] C API to manage <emph style="italic">carets</emph> in Tk. <emph style="italic">caret</emph> is the term for where text of graphics will be inserted. It is necessary for correct accessibility functionality (to know where to shift focus), and for location the IME or XIM input box to handle complex character input (e.g. Asian character sets).</abstract>
<body><section title="Rationale">
<para>Tk has up until now not managed the caret within its windows. This has led to it being not Windows Accessibility certifiable. On Windows, this also cause the IME window to show in the top-left corner of the window (somewhat OK for entries, bad for text widgets). On X, this meant that Tk had to use the root-window style XIM input, which is a poor second to over-the-spot XIM input. Managing the caret corrects these problems.</para>
<para>Exposing the functionality at the Tcl level allows extension writers to use the functionality without having to make Tk version API checks. A simple</para>
<verbatim><vline encoding='base64'>ICAgY2F0Y2gge3RrIGNhcmV0ICR3IC14ICR4IC15ICR5fQ==</vline></verbatim>
<para>will suffice to work across versions.</para>
</section>
<section title="Specification">
<verbatim><vline encoding='base64'>ICAgdGsgY2FyZXQgd2luZG93ID8teCB4UG9zPyA/LXkgeVBvcz8gPy1oZWlnaHQgaGVpZ2h0Pw==</vline><vline encoding='base64'>ICAgdm9pZCBUa19TZXRDYXJldFBvcyAoVGtfV2luZG93IHRrd2luLCBpbnQgeCwgaW50IHksIGludCBoZWlnaHQp</vline></verbatim>
<para><emph style="italic">-height</emph> specifies the height of the input line and is important because Windows and X interpret the x,y coordinates differently (top-left and bottom-left respectively), so it must be adjusted by height for X. If no height is specified, the height of the window passed in will be used.</para>
<para>I chose to use the <emph style="italic">-option value</emph> format because it allows for future extensibility. There are APIs to control the font and other aspects of the IME/XIM input window that appears, but management of these is not covered in this tip.</para>
</section>
<section title="Reference Implementation">
<para>The Tk_SetCaretPos implementation is currently in the core. It needs to be modified to move the caret information to be per display, instead of per process.</para>
<para>File: <emph style="italic">tk/mac/tkMacXStubs.c</emph></para>
<para>File: <emph style="italic">tk/win/tkWinX.c</emph></para>
<para>File: <emph style="italic">tk/unix/tkUnixKey.c</emph></para>
<para>Function: <emph style="italic">Tk_SetCaretPos</emph></para>
</section>
<section title="Comments">
<para>The current implementation at the C level was implemented with the assistance of Keiichi Takahashi (BitWalk), Koiichi Yamamoto, Moo Kim (NCR), and Mike Fabian (SuSE). It has been tested on Windows 98/2000/XP and SuSE 7.3 using kinput/canna2.</para>
</section>
<section title="Copyright">
<para>This document has been placed in the public domain.</para>
</section>
</body></TIP>

