Symbian3/SDK/Source/GUID-DC0E3782-82EF-5104-937C-41F24DF1E1CA.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Tue, 20 Jul 2010 12:00:49 +0100
changeset 13 48780e181b38
parent 0 89d6a7a84779
permissions -rw-r--r--
Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License 
"Eclipse Public License v1.0" which accompanies this distribution, 
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
    Nokia Corporation - initial contribution.
Contributors: 
-->
<!DOCTYPE concept
  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept xml:lang="en" id="GUID-DC0E3782-82EF-5104-937C-41F24DF1E1CA"><title>How to set the cursor</title><prolog><metadata><keywords/></metadata></prolog><conbody><p>The code in this section sets the <keyword>line cursor
        margin</keyword> and line and <keyword>text cursor</keyword> visibility. In order to display the text cursor, a window group must have been set when the text view was constructed. Alternatively, one may be set by calling <xref href="GUID-CF377A98-F11F-380F-AD10-7F3E261D4421.dita#GUID-CF377A98-F11F-380F-AD10-7F3E261D4421/GUID-B9282DE0-09BF-308C-8105-61272B79AC80"><apiname>CTextView::SetDisplayContextL()</apiname></xref>. Before a <keyword>line
        cursor</keyword> can be displayed, the line cursor margin width must be set and a bitmap line cursor must be specified. </p> <p>The following code sets the <keyword>line cursor
        margin</keyword> width to 20 pixels and the <keyword>label
        margin</keyword> width to zero.</p> <ul><li id="GUID-ADDB082D-EB96-5FA7-9533-CDEF32D4C8F7"><p>After the margin width is set, call <xref href="GUID-CF377A98-F11F-380F-AD10-7F3E261D4421.dita#GUID-CF377A98-F11F-380F-AD10-7F3E261D4421/GUID-F30E2687-36D6-3C7E-AE6C-7735981853F2"><apiname>CTextView::DrawL()</apiname></xref> to ensure the line cursor will be visible.</p> </li> <li id="GUID-61752E09-7AFA-595A-95B1-6D2DF75FCDE8"><p>Load in the bitmap used to represent the line cursor. </p> </li> <li id="GUID-AA9E0A3E-5247-5B88-B70F-2302815FC715"><p>Call <xref href="GUID-CF377A98-F11F-380F-AD10-7F3E261D4421.dita#GUID-CF377A98-F11F-380F-AD10-7F3E261D4421/GUID-DA488293-4E53-32B6-A852-C28AC9ECEACE"><apiname>CTextView::SetCursorVisibilityL()</apiname></xref> to select both cursors for display.</p> </li> </ul> <codeblock id="GUID-9CF0ACFB-574A-5664-AFC2-9263F8888D56" xml:space="preserve">iTextView-&gt;SetMarginWidths(0,20);
        // zero label margin, 20 pixel line cursor margin
iTextView-&gt;DrawL(iViewRect); // required to update the view 
// Set bitmap to represent line cursor. First load it in.
iBitmap=new(ELeave) CFbsBitmap();
iBitmap-&gt;Load(_L("\\data\\CURSORS.MBM"));
iTextView-&gt;SetLineCursorBitmap(iBitmap);
iTextView-&gt;SetCursorVisibilityL(TCursor::EFBothCursors);</codeblock> </conbody></concept>