×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Aug 2005
    Posts
    28

    Get line number from CEikEdwin

    Hi I'd like to get which line I'm in with CEikEdwin. The function CursorPos() returns the cursor position, but not the line number. I'd like to do this so if ever I'm on the first line of a multiline edwin, I could SerFocus() on another control. Please help. Thanks!

  2. #2
    Registered User
    Join Date
    Nov 2005
    Location
    PHILIPPINES
    Posts
    16

    Post Re: Get line number from CEikEdwin

    Check this out:

    I start by counting the number of lines in the text box:
    Code:
    	iRtEd->MoveCursorL(TCursorPosition::EFPageUp, EFalse);
    
    	while (iRtEd->CursorPos()!=iRtEd->TextLength()) {
    		iRtEd->MoveCursorL(TCursorPosition::EFLineDown, EFalse);
    		intMaxLines++;
    	}
    
    	intMaxLines -= 3 ;
    Then I make sure I keep track of the current cursor position by monitoring navigational keystrokes:

    Code:
    TKeyResponse CRTF_XMLContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType )
    {
    	switch(aKeyEvent.iCode) {
    		case EKeyUpArrow:{
    			if (intLineCounter > 0) {
    				intLineCounter--;
    				iRtEd->MoveDisplayL(TCursorPosition::EFLineUp);
    			}
    			break;
    			}
    
    		case EKeyDownArrow:{
    			if (intLineCounter < intMaxLines ) {
    				intLineCounter++;
    				iRtEd->MoveDisplayL(TCursorPosition::EFLineDown);
    			} else {
    				iEikonEnv->InfoMsg(_L("Past end of line."));
    			}
    			break;
    			}
    
    		default: { // trip lang
    			return iRtEd->OfferKeyEventL(aKeyEvent, aType);
    			break;
    			}
    	}
    	
    	TBuf<255> msg;
    	msg.AppendNum(intLineCounter);
    	msg.Append(_L("/"));
    	msg.AppendNum(intMaxLines);
    
    	iEikonEnv->InfoMsg(msg);
    	return EKeyWasNotConsumed;
    }
    Using the codes above, I can track what line I'm in and the total number of lines there is in the textbox. My textbox even have an embeded image in it which occupies 1 whole line.

    NOTE: Be sure to call the counting code block again when you update the content of the text box or you may either not be able to scroll down the bottom of your texts or move past the lines of your text, that's when your application crash and it's the least we all want to happen.

    Enjoy!
    Last edited by grayram; 2005-11-25 at 06:34.

Similar Threads

  1. Replies: 3
    Last Post: 2007-01-18, 11:27
  2. problem with Code Warrior 5.2
    By mayankkedia in forum Symbian
    Replies: 4
    Last Post: 2006-06-22, 08:26
  3. code warrior problems
    By mayankkedia in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 2
    Last Post: 2004-10-25, 06:59
  4. problem with codewarrior 5.2
    By mayankkedia in forum Symbian Tools & SDKs
    Replies: 3
    Last Post: 2004-09-27, 16:08
  5. Personal
    By JSmith77 in forum PersonalJava
    Replies: 4
    Last Post: 2003-07-30, 12:52

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×