This is a migrated thread and some comments may be shown as answers.

ClientSelectionChange outside of ContentArea

1 Answer 40 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Dave
Top achievements
Rank 1
Iron
Veteran
Iron
Dave asked on 11 Oct 2020, 03:29 PM

Hi,

The documentation indicates that the ClientSelectionChange event will be raised whenever the user changes selection "within the ContentArea."   I'm finding that the event is raised whenever the mouse is clicked anywhere, e.g. srollbar, toolbar, etc.   Is this expected behavior, or am I missing something?   In the project below, set a breakpoint in the ClientSelectionChange event handler.  Click on "Some Content", breakpoint is hit as expected.  Now click on Scrollbar.  Breakpoint is hit again, even though the selected element remains "Some Content". This is unexpected.

Is this a bug?  Or am I not understanding.

Using editor iframe mode.  Telerik version: 2020.2.617

Dave

Default.aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Default" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
            <Scripts>
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
            </Scripts>
        </telerik:RadScriptManager>
 
        <script type="text/javascript">
 
            //Put your JavaScript code here.
            function onClientSelectionChange(editor, args) {
                var lElement = editor.getSelectedElement();
            }
 
        </script>
 
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        </telerik:RadAjaxManager>
 
        <div>
            <telerik:RadEditor ID="RadEditor1" runat="server"
                OnClientSelectionChange="onClientSelectionChange"
            />
        </div>
 
    </form>
</body>
</html>

Default.aspx.cs

using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
using System.Data;
using System.Configuration;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Telerik.Web.UI;
 
public partial class Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        RadEditor1.Content = "<!DOCTYPE html><html><body><div id='myWrapper' style='height: 300px;'><span id='rspn'>Some Content</span></div></body></html>";
    }
}

1 Answer, 1 is accepted

Sort by
0
Accepted
Rumen
Telerik team
answered on 14 Oct 2020, 02:46 PM

Hi Dave, 

The selectionChanged event is one of the most widely and often used RadEditor events by the control and is raised when:

  • focus the content area
  • clicking in the content area
  • selection in the content area
  • typing
  • scrolling
  • a toolbar command is fired
  • select and delete a table
  • keypress
  • keyup
  • pasting content
  • setting content

For your convenience, I have attached the main JS file of RadEditor where you can check yourself which commands and features of the control are calling this.raiseEvent("selectionChange".

I agree with you that the help article should provide this information and it will be updated in the next hour with the content below: 

As a small note of gratitude for reporting this, I updated your Telerik points.

Best Regards,
Rumen
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).

Tags
Editor
Asked by
Dave
Top achievements
Rank 1
Iron
Veteran
Iron
Answers by
Rumen
Telerik team
Share this question
or