[CLOSED] How to enable browser right click context menu on specific controls?

  1. #1

    [CLOSED] How to enable browser right click context menu on specific controls?

    Hi,

    I have the following code preventing a native right-click context menu on the entire document:

        <ext:ResourceManager ID="ResourceManager1" runat="server" DirectMethodNamespace="X">
            <Listeners>
                <DocumentReady Handler="
                                        Ext.get(window.document).on('contextmenu', function (e) {
                                                            e.preventDefault();
                                                            return false;
                                                        });" />
            </Listeners>
        </ext:ResourceManager>
    How can I re-enable this behavior, preferably in the same block of code, for specific controls like TextArea?
    Last edited by Daniil; Aug 17, 2012 at 2:30 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Probably, replacing
    Ext.get(window.document)
    with
    TextArea.getEl()
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi,

    Probably, replacing
    Ext.get(window.document)
    with
    TextArea.getEl()
    Sorry, I didn't follow. If I place the call to

                                        TextArea1.getEl().on('contextmenu', function (e) {
                                                                                        e.preventDefault();
                                                                                        return false;
                                                                                   }
                                        );
    instead of my initial code block, it doesn't do what I need because that makes context menu available everywhere except the TextArea. I need to re-enable the right-click context menu for the TextArea control disabling it elsewhere.
  4. #4
    Ok, I misunderstood the requirement.

    Then you need to analyze
    e.getTarget()
    to ensure the event doesn't occur in a TextArea.
  5. #5
    Thanks! I used this check to disable the context menu everywhere except TextAreas:

    if(e.getTarget().type!='textarea'){
          e.preventDefault();
          return false;
    }
    Wish I could find something more elegant like
    if(e.getTarget() instanceof Ext.net.TextArea)
    but it seems to be unavailable.
  6. #6
    Well, this
    e.getTarget()
    just return a DOM object, it knows nothing about JavaScript classes.

    Commonly, the following thing is used in such cases:
    Ext.fly(e.getTarget()).hasClass('x-form-textarea');
    Just a note - there is no Ext.net.TextArea class in Ext.NET. It is named Ext.form.TextArea.
  7. #7
    Thanks for the clarification Daniil! You can mark this thread as closed.

Similar Threads

  1. Replies: 0
    Last Post: Mar 29, 2012, 12:50 PM
  2. [CLOSED] Rendering new controls dynamically with a context menu
    By logicspeak in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: Oct 24, 2011, 10:29 AM
  3. [CLOSED] Tab Context menu help
    By SymSure in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Mar 31, 2011, 5:08 PM
  4. Context Menu in desktop
    By dotnet in forum 1.x Help
    Replies: 7
    Last Post: Sep 16, 2010, 4:30 PM
  5. How to disable the browser's right click menu?
    By dbassett74 in forum 1.x Help
    Replies: 1
    Last Post: Apr 23, 2009, 8:26 PM

Posting Permissions