Knowledgebase Home Page  >  RapidSpell Web ASP.NET  >  Behavior Customization
Search the Knowledge Base
Controlling the tab (or other key) behavior in RapidSpellWInlineTextBox explicitly.
https://keyoti.com/kb/Default.aspx?ToDo=view&questId=188&catId=55

Options

Print this page
Email this to a friend
The RapidSpellWInlineTextBox is an editable IFrame, and as such relies on the host browser for default behavior.  This example captures the tab key, and moves focus to the next control.  Note that it relies on the tabindex attribute being set in the other controls on the page, as there is no simple way to automatically determine default tab order otherwise.
 
 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="FocusTest.aspx.cs" Inherits="nonAJAX_FocusTest" %>

<%@ Register TagPrefix="rapidspellweb" Namespace="Keyoti.RapidSpell" Assembly="Keyoti.RapidSpellWeb.ASP.NETv2" %>

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

<title>Capture</title>

<script>

function key_down(source, e){

var chr;

if(e.charCode)//MOZILLA

chr = e.charCode;

else

chr = e.keyCode;

if(9 == chr ){

e.returnValue = false;

if(e.preventDefault){

e.preventDefault();

e.cancelBubble = true;

}

//find next ctrl

var currTabInd = source._getTBS().shadowTB.tabIndex;

var elToFocus = null;

var firstTabEl = null;

var el;

for(var i=0; i<window.document.forms[0].elements.length && elToFocus==null; i++){

el = window.document.forms[0].elements[i];

if(el.tabIndex && el.tabIndex == currTabInd+1 )

elToFocus = el;

if(el.tabIndex && el.tabIndex == 1 )

firstTabEl = el;

}

if(elToFocus==null)elToFocus = firstTabEl;

if(elToFocus!=null){

var found = false;

for(var i=0; i<rsw_tbs.length && !found; i++){

if(rsw_tbs[i].shadowTB.id==elToFocus.id){

rsw_tbs[i].focus();

found=true;

}

}

if(!found)elToFocus.focus();

}

}

}

onload=function(){

<%= tb.ClientSideObject %>.OnKeyDown = key_down;

}

</script>

</head>

<body >

<form id="form1" runat="server">

<div>

<rapidspellweb:RapidSpellWInlineTextBox ID="tb" runat="server" tabindex="1" />

<textarea tabindex="3"></textarea>

<textarea tabindex="4"></textarea>

<button tabindex="2" runat="server"></button>

</div>

</form>

</body>

</html>


Related Questions:

Attachments:

No attachments were found.