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

Browser Select All chooses the entire page when a modal window is open

3 Answers 156 Views
Window
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 23 Feb 2017, 11:09 AM

The entire page, including the non-window content, is selected when a modal window is open and the browser select all (Ctrl-A) is performed.

Q: Is there a way to have Ctrl-A select only the modal content ?

Sample is in the Dojo: http://dojo.telerik.com/uzeCA/3

Thanks,

Richard

3 Answers, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 24 Feb 2017, 03:53 PM
Hello Richard,

Selecting the text outside the modal window is a browser behavior that we do not have control over and it is not specific to using the Kendo UI Window. Nevertheless we created a sample dojo, which shows how through custom logic and detecting the Ctrl + A keys press (you can see the following stackoverflow thread) you can select only the text in the window. I hope it's helpful and points you in the right direction.

Regards,
Ivan Danchev
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Richard
Top achievements
Rank 1
answered on 24 Feb 2017, 05:57 PM

Hi Ivan:

Thanks for the sample.

I pursued a css solution and came up with the following that uses unselectable.

// jQuery extensions for elg
(function($){
    $.fn.disableSelection = function() {
        return this
                 .attr('unselectable', 'on')
                 .css('user-select', 'none')
                 .on('selectstart', false);
    };
 
    $.fn.enableSelection = function() {
        return this
                 .removeAttr('unselectable')
                 .css('user-select', 'auto')
                 .off('selectstart');
    };
})(jQuery);
 
 
function myPreview(title, message, options) {
    if (!options) options = {};
    var config = {
        title: title,
        width: "85%",
        height: "85%",
        scrollable: true,
        modal: true,
        visible: false,
        close: function (e) {
            $('#previewWindow').parent().siblings().enableSelection();
            this.destroy();
        }
    };
    $("<div id='previewWindow'></div>")
    .appendTo("body")
    .kendoWindow($.extend(config, options))
    .data('kendoWindow').content(message).center().open();
 
    $('#previewWindow').siblings().disableSelection();
    $('#previewWindow').parent().siblings().disableSelection();
}
0
Ivan Danchev
Telerik team
answered on 28 Feb 2017, 11:52 AM
Hi Richard,

I am glad you have found an approach that allows to achieve the desired behavior. Thank you for sharing it.

Regards,
Ivan Danchev
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Window
Asked by
Richard
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
Richard
Top achievements
Rank 1
Share this question
or