Atitit. get up down left right neighbor's method design of soft keyboard ..
Left right can use the next prev directly.
Up-down can be judged using the pix ... Get Next Element of the position ... Compare Top
However , if the cross- block ... just all that can be used Positon solution. ...
Judging is not next block ... can use span 10px; .... because Block size is not as large .. Belle can use the centerline, too. ..
if (left_cur+10 >focusobj_left && left_cur-10<focusobj_left && top_cur>focusobj_top)
Author :: ★ (Attilax) >>> nickname : old-Wow paw &NBSP; ( &NBSP; full name:: ATTILAX&NBSP;AKBAR&NBSP;AL&NBSP;RAPANUI&NBSP, Attilax &NBSP, " " Al &NBSP; Rapa Nui &NBSP, &NBSP; Kanji name: Ayron, Email:[email protected]
reprint Please indicate source: http://www.cnblogs.com/attilax/
JavaScript Document
function SearchBox ()
{
}
Searchbox.prototype.removefocus=function ()
{
var arr=$ (". SearchBox. Key");
Arr.each (function (index, Element) {
$ (Element). Removeclass ("hover");
});
var now=$ (". Hover"). Get (0);
}
Searchbox.prototype.getfocuscontrol=function ()
{
var now=$ (". Hover"). Get (0);
return now;
}
Searchbox.prototype.key_up_event=function (Curfocusobj)
{
}
Searchbox.prototype.key_down_event=function (Curfocusobj)
{
var focusobj_top = $ (curfocusobj). Offset (). Top;
var focusobj_left = $ (curfocusobj). Offset (). Left;
Alert ("cur xy:" +focusobj_left+ "" +focusobj_top);
var Isfind=false;
var arr=$ (". SearchBox. Key");
Arr.each (function (index, Element) {
if (element). html () = = "J")
Alert ("--");
if (Element). attr ("id")!=$ (curfocusobj). attr ("id"))
$ (Element). Removeclass ("hover");
if (Element). attr ("id") ==$ (curfocusobj). attr ("id"))
return true; Continue
var top_cur= $ (Element). Offset (). Top;
var left_cur= $ (Element). Offset (). Left;
if (left_cur+10 >focusobj_left && left_cur-10<focusobj_left && top_cur>focusobj_top)
{
$ (Element). addclass ("hover");
Isfind=true;
return false; Break
}
});
if (Isfind)
$ (curfocusobj). Removeclass ("hover");
}
Searchbox.prototype.key_left_event=function (Curfocusobj)
{
}
Searchbox.prototype.key_rit_event=function (Curfocusobj)
{
}
Searchbox.prototype.key_enter_event=function (Curfocusobj)
{
var value = curfocusobj.html ();
$ ('. SearchBox. TextBox '). Append (value);
}
Searchbox.prototype.bindkeyevent=function ()
{
var arr=$ (". SearchBox. Key");
Arr.each (function (index, Element) {
var id= "Key_aid_" +INDEX;
$ (Element). attr ("id", id);
//
// objevtmap[id+ "--left"]=function (Element)
// {
//
//
// }
objevtmap[id+ "--enter"]=function (Element)
{
This.key_enter_event ($ (element));
}
objevtmap[ID]=function (evt,element)
{
if (evt== "down")
This.key_down_event ($ (element));
if (evt== "up")
This.key_up_event ($ (element));
if (evt== "left")
{
This.key_left_event ($ (element));
};
if (evt== "RIT")
{
This.key_rit_event ($ (element));
}
};
});
}
Atitit. Get up and down left right neighbor's method soft keyboard design: