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

AccessKey to perform a click

4 Answers 130 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Michael Arocho
Top achievements
Rank 2
Michael Arocho asked on 20 Aug 2009, 09:44 PM
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?

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 21 Aug 2009, 12:58 PM
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
0
Michael Arocho
Top achievements
Rank 2
answered on 24 Aug 2009, 11:24 AM
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?
0
Yana
Telerik team
answered on 25 Aug 2009, 01:26 PM
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.
0
Michael Arocho
Top achievements
Rank 2
answered on 25 Aug 2009, 01:33 PM
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();

}
Tags
Menu
Asked by
Michael Arocho
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Michael Arocho
Top achievements
Rank 2
Yana
Telerik team
Share this question
or