×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Regular Contributor
    Join Date
    May 2008
    Posts
    73

    How to judge whether the cursor is at the end of a line or not?

    hi everybody here,
    I donnot konw how to judge whether the cursor is at the end of line in a CEikEdwin control when editing a note.
    Is there any API of CEikEdwin or any method to figure it out?
    Could someone help me? Any advise is appreciated!

  2. #2
    Super Contributor
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    9,968

    Re: How to judge whether the cursor is at the end of a line or not?

    You have to parse the text at the cursor position to know if it is a newline or not . No API available to known the newline at cursor position in CEikEdwin class.

    Note: DO not Muti-Post.

  3. #3
    Regular Contributor
    Join Date
    May 2008
    Posts
    73

    Re: How to judge whether the cursor is at the end of a line or not?

    Thank you.
    "DO not Muti-Post", actually i am not mean to, i placed this post in symbian c++ because i didn't see Symbian User Interface division.I will go and delete the post from symbian c++.

    Quote Originally Posted by skumar_rao View Post
    You have to parse the text at the cursor position to know if it is a newline or not . No API available to known the newline at cursor position in CEikEdwin class.

    Note: DO not Muti-Post.

  4. #4
    Regular Contributor
    Join Date
    May 2008
    Posts
    73

    Re: How to judge whether the cursor is at the end of a line or not?

    There is no newline stored in the text.It's determined by the control when to start a newline,perhaps through the character number per text line.Because the amount of characters one line in CEikEdwin control is changable among different resolutions, so maybe the best way to solve this problem is using existing API of the control, now without API provided how can i code and keep it layout-independent?

    Quote Originally Posted by skumar_rao View Post
    You have to parse the text at the cursor position to know if it is a newline or not . No API available to known the newline at cursor position in CEikEdwin class.

    Note: DO not Muti-Post.

  5. #5
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,750

    Re: How to judge whether the cursor is at the end of a line or not?

    Quote Originally Posted by curiouswalker View Post
    There is no newline stored in the text.It's determined by the control when to start a newline,perhaps through the character number per text line.Because the amount of characters one line in CEikEdwin control is changable among different resolutions, so maybe the best way to solve this problem is using existing API of the control, now without API provided how can i code and keep it layout-independent?
    In that case I can not really see what you expect. CEikEdwin can do word-wrapping automatically for you (that is the default behavior in fact), thus it is already layout-independent. What else do you need?
    Anyway, if you really want to experiment, and do not care about FEP-transactions (for example it is a read-only editor), you can try something like this:
    Code:
    TInt pos=iEditor->CursorPos();
    iEditor->MoveCursorL(TCursorPosition::EFLineEnd,EFalse);
    TBool endofline=pos==iEditor->CursorPos();
    iEditor->SetCursorPosL(pos,EFalse);

  6. #6
    Regular Contributor
    Join Date
    May 2008
    Posts
    73

    Red face Re: How to judge whether the cursor is at the end of a line or not?

    Thank you so much for your reply.

    The real situation is that I detected an error in my notepad program.After the user deleted the last line of a note whose content is longer than a page, the designer would expect the editor to roll down by one line, just as some programs with editor, e.g. Messaging,Contacts,etc. do for you. But in my notepad, the CEikEdwin just does not do this.I don't know why this happens. I have an observer of Notepad Editable window control and an editor dialog as the container, When an event happens, then it will be caught and sent to C***EventHandler, member function of my observer, to be handled.

    Just like you said, it's usually the CEikEdwin's job to do that.But here it seems to do nothing, so i have to make a call to draw function to redraw the control in C***EventHandler when the very event occurred and then things become OK, I really don't know why it affects.Unfortunately it will result in many other bugs due to too much call to draw(almost every time a char is typed), hence i have to figure out another way to solve this problem or a better way to control the calling to draw function.

    I posted this thread for figuring out the method,perhaps some condition statement, to identify the very event, the case Editor needs to roll down one line.then I just call the draw function under the condition i trapped in C***EventHandler and this could avoid calling the draw function too often and some bugs are also avoided.


    Quote Originally Posted by wizard_hu_ View Post
    In that case I can not really see what you expect. CEikEdwin can do word-wrapping automatically for you (that is the default behavior in fact), thus it is already layout-independent. What else do you need?
    Anyway, if you really want to experiment, and do not care about FEP-transactions (for example it is a read-only editor), you can try something like this:
    Code:
    TInt pos=iEditor->CursorPos();
    iEditor->MoveCursorL(TCursorPosition::EFLineEnd,EFalse);
    TBool endofline=pos==iEditor->CursorPos();
    iEditor->SetCursorPosL(pos,EFalse);
    Last edited by curiouswalker; 2008-07-06 at 14:35.

  7. #7
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,750

    Re: How to judge whether the cursor is at the end of a line or not?

    You can also try what CTextView::SetViewL really does (based on its documentation it could help if you specify last character of document, last line of the editor and EFViewBottomOfLine, but I have never seen it in action).

Similar Threads

  1. i cant build helloworld project
    By akhin in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 2
    Last Post: 2008-12-22, 12:38
  2. Error while making sis file
    By lalitjadiya in forum Symbian
    Replies: 9
    Last Post: 2008-05-20, 17:18
  3. Replies: 8
    Last Post: 2007-10-16, 15:05
  4. carbidec++ helloworld project problem
    By akhin in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 0
    Last Post: 2007-03-11, 12:40
  5. carbide build problem help please
    By berkcekisbas in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 1
    Last Post: 2006-09-26, 19:41

Posting Permissions

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