Editor Control: Why is the line spacing double?

Posted by: imgodot on 7 March 2018, 10:41 am EST

    • Post Options:
    • Link

    Posted 7 March 2018, 10:41 am EST

    When the editor control is in rich-text mode and you press the ENTER key it double-spaces the line.

    If you press SHIFT+ENTER it single-spaces the line.

    How can I make the ENTER key behavior match SHIFT+ENTER?

    Thanks.

    – Paul

  • Posted 7 March 2018, 3:02 pm EST

    Hi Paul!

    You can check if the user has pressed ENTER key then you need to suppress this and send SHIFT+ENTER keys combination.

    bool suppressNextEnter = true;
    
    private void C1Editor1_KeyPress(object sender, KeyPressEventArgs e)
    {
                if (e.KeyChar == 13)
                {
                    if (suppressNextEnter)
                    {
                        e.KeyChar = (char)0;
                        e.Handled = true;
                    }
                    else
                        this.suppressNextEnter = true;
                }
    }
    
    private void C1Editor1_KeyUp(object sender, KeyEventArgs e)
    {
                if (e.KeyValue == 13 && !e.Shift)
                {
                    e.Handled = true;
                    SendKeys.Send("+{ENTER}");
                    this.suppressNextEnter = false;
                }
    }
    
    private void C1Editor1_KeyDown(object sender, KeyEventArgs e)
    {
                if (e.KeyValue == 13 && e.Shift)
                {
                    this.suppressNextEnter = false;
                }
    }
    

    Best regards,

    Meenakshi

  • Posted 13 March 2018, 3:49 am EST

    Meenaksi,

    Thanks for the reply. Note: I was able to implement the specific functionality using just the KeyDown event.

    However, I now have the realization that I still need to allow the user to be able to output a new paragraph (the original ENTER key processing) because, otherwise, the user could not have mixed indents in one control.

    The “normal” ENTER key would create a new paragraph (HTML “

    ”).

    The “normal” SHIFT+ENTER key would output a newline (HTML “

    ”).

    I can have ENTER perform a SendKey(<shift+enter>) BUT …

    I was unable to get the normal ENTER processing because it would be translated to SHIFT+ENTER and the code would get into a loop.

    Can you see any way that I can get the ENTER key alone to perform a newline (translating it to a SHIFT+ENTER like your solution above) and also get SHIFT+ENTER or some other key combination to perform the “normal” ENTER processing of creating a new paragraph?

    Thanks.

    – Paul

  • Posted 14 March 2018, 7:07 pm EST

    Hi,

    Please note we cannot achieve your requirement because this is the designed behavior of C1Editor.

    Hope, it clarifies for you.

    Thanks,

    Singh

  • Posted 21 June 2019, 5:51 am EST

    this is a real issue. is there any other solution. Why make this soo complicated? Is this being fixed? This wasn’t like this in the previous versions.

  • Posted 24 June 2019, 9:38 pm EST

    Hello,

    I understand that you still observe this behavior.

    For further investigation, which builds have you been using previously where the behavior was different?

    Thanks.

  • Posted 25 June 2019, 12:08 am EST

    Was using version 4.0.20132.203 on VS2013 now using version 4.0.20182.314 on VS2017.

  • Posted 25 June 2019, 12:31 am EST

    version 2.0.20132.203 was also working fine.

  • Posted 26 June 2019, 3:31 pm EST

    Hello,

    I have responded to the case on related SupportOne ticket #386166.

    Please refer the same.

    Thanks.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels