AccessKey to perform a click

5 posts, 0 answers
  1. Michael Arocho
    Michael  Arocho avatar
    29 posts
    Member since:
    Mar 2009

    Posted 20 Aug 2009 Link to this post

    Hi,

    I have a RadMenu with 1 level of items.  I have given the "New" menu item an AccessKey of N.  When I hit on my keyboard alt+N it will select the menu item but not activate its postback like a click or hitting enter while focused on it would.  Is there a way to tell the control when its accesskey have been activated to perform a click?
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 21 Aug 2009 Link to this post

    Hello Michael,

    I tried explicitly invoking postback by click() method of RadMenuItem client object in OnClientItemFocus client event. Give a try with this code and see whether it suits your need.

    ASPX:
     
    <telerik:RadMenu ID="RadMenu1" OnClientItemFocus="OnClientItemFocus" runat="server" OnItemClick="RadMenu1_ItemClick" > 
        <Items> 
            <telerik:RadMenuItem runat="server" Text="New" AccessKey="N"
            </telerik:RadMenuItem> 
             . . . 
        </Items> 
    </telerik:RadMenu> 

    JavaScript:
     
    <script type="text/javascript"
    function OnClientItemFocus(sender, args) 
        if(args.get_item().get_text() == "New"
        { 
            args.get_item().click(); 
        } 
    </script> 

    -Shinu
  3. Michael Arocho
    Michael  Arocho avatar
    29 posts
    Member since:
    Mar 2009

    Posted 24 Aug 2009 Link to this post

    Hi,

    I had actually already thought of that, but one of the problems is that also have the ability to tab through the items.  If i put this code in there when they tab over the new menu item, it will cause the action to occur, which we do not want to do.  Is there any way to identify that the menu items accesskey has been activated?
  4. Yana
    Admin
    Yana avatar
    5037 posts

    Posted 25 Aug 2009 Link to this post

    Hi Michael,

    Could you please try it like this:

    function OnClientItemFocus(sender, args)  
    {  
        if(args.get_item().get_text() == "New")  
        {  
            if(event.altKey) 
                args.get_item().click();  
        }  
    }  

    Best wishes,
    Yana
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. Michael Arocho
    Michael  Arocho avatar
    29 posts
    Member since:
    Mar 2009

    Posted 25 Aug 2009 Link to this post

    I was actually able to work around the issue.

    I created input button controls with height and width to 0 at the bottom of the page.  They have an accesskey and javascript that will get the menu item and click on it.

    <input type="button" style="height:0px; width:0px" accesskey="n" onclick="HandleNew();" />

    function HandleNew() {

        document.getElementById('<%= mnuNew.ClientID %>').click();

    }
Back to Top