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

Focus not lost when using tab instead of mouse click

3 Answers 117 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Nolan
Top achievements
Rank 1
Nolan asked on 06 Nov 2008, 06:49 PM
I have a row of items, including a RadTimePicker with a TimePopupButton.  If I click the popup, and then click the mouse out of the popup, the popup closes.  If instead of clicking I use the tab key, the popup stays open until I click somewhere.  Is this intentional behavior, and if so is there a way to change it so the popup closes when the tab button is used to alter the input focus?  Here's the RadTimePicker definition I currently have.

                        <telerik:RadTimePicker ID="SurgeryTime" runat="server" MinDate="1780-01-01" Culture="English (United States)" Width="80" style="margin-right: 15px;"   >
                            <TimePopupButton CssClass="" />
                            <TimeView ID="TimeView1" StartTime="1:0:0" EndTime="23:00:00" Interval="0:15:0" Columns="5"
                            TimeFormat="HH:mm" runat="server">
                            </TimeView>

                            <DateInput ID="DateInput1" DateFormat="HH:mm" runat="server">
                            </DateInput>

                            <Calendar UseColumnHeadersAsSelectors="True" UseRowHeadersAsSelectors="True" runat="server">
                            </Calendar>
                            <DatePopupButton CssClass="" Visible="False" />
                        </telerik:RadTimePicker>&nbsp;

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 07 Nov 2008, 10:22 AM
Hi Nolan,

My suggection to achieve this feature is to add the following Javascript, which will check for the keypress event in the document.

JavaScript:

<script type="text/javascript"
document.onkeypress = keyPress; 
function keyPress(ev) 
    ev || (ev = window.event); 
    var code = (ev.keyCode ? ev.keyCode: (ev.charCode ? ev.charCode: ev.which)); 
    if (code == 9) // keycode for TAB key
    { 
        var picker = $find("<%= RadTimePicker1.ClientID %>"); 
        picker.hideTimePopup(); 
        return 9; 
    } 
</script> 


Thanks,
Shinu.
0
John Snyder
Top achievements
Rank 1
answered on 16 Dec 2008, 04:22 PM
You may want to consider using onkeydown or onkeyup since onkeypress does not capture the Tab key in IE7 (and possibly some others).  Otherwise it worked well for me.  I have 3 calendars so I just hide all 3 of them when the tab key is pressed.
0
Calvin Bowens
Top achievements
Rank 1
answered on 10 Feb 2009, 08:47 PM
I tried this (onkeyup since i'm using IE7) and it opens the calendar then immediately closes it.  Any suggestions?
Tags
Calendar
Asked by
Nolan
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
John Snyder
Top achievements
Rank 1
Calvin Bowens
Top achievements
Rank 1
Share this question
or