|
我是2.1的,嘗試了一下,解決了just type輸入中文時,出現英文首字母的問題.6 J9 G( e; Y$ ?- {6 X
e.g. 以前拼音輸入"你好"會出現"n你好",修改後只會出現"你好"9 l' c F! F" Z- P2 s* b/ M
* C4 B+ Y! _/ o& l' K$ p' j; P
0 C8 M1 F$ H1 t5 s F( ]$ O/usr/lib/luna/system/luna-applauncher/app/controllers/global-search-assistant.js
9 W5 H d% |" B* E0 i {- B1 r) A S0 _7 q4 K
原本內容:- V9 T5 F1 C s4 q( D
// try to handle the very first key event
) Q8 k1 h. f/ _) r7 I ~ var s;
3 i$ H/ r& E' y$ A% x if (Mojo.Char.isPrintableChar(event.keyCode, true) && !event.ctrlKey) {
. c: G; E/ s1 c s = String.fromCharCode(event.keyCode);! E# d* {: o8 g8 H& r8 C7 b
}
1 N4 Y1 Y$ k# V* M: b3 g if (s && this.searchTerm.length==0 && this.searchPressHoldTerm.length==0) {
' c; Z4 D# y3 c! _9 d m4 o // first valid key press event
5 D1 ]. A4 F+ V this.onActivate(s);
+ I; T; S& j: ^% r7 q, S- g, V this.updateSearchTerm(s, true);6 y! V* m, L" Y4 c+ Q
# j* s7 H9 N b! X3 f; V
// we manually updated the search field
3 u- h2 Z9 L% @, { event.preventDefault();2 F& r& }+ H" i7 z: H
}
/ Q+ M4 o4 c5 n9 Q% H0 [, p V- v7 t修改後內容:: _" m* y$ H7 c
// try to handle the very first key event4 \" c& Z9 T$ y; U8 }9 `
var s=/^\w+$/;) m+ D, G3 t. N* T" O
if (Mojo.Char.isPrintableChar(event.keyCode, true) && !event.ctrlKey) {
6 c4 u' I1 F9 g- \- h s = String.fromCharCode(event.keyCode);
1 y0 L: ?( X0 E( d/ g }. [+ }% E t* Z
if (s && this.searchTerm.length==0 && this.searchPressHoldTerm.length==0) {3 J: R! T9 c# T1 W6 y- [! G$ ?
// first valid key press event
# K: `. i% U/ R; e this.onActivate(s);1 ^9 J8 x1 L1 \: n4 n
if(!s.test(str)) 2 e/ p9 I& L( ~0 k# {* t
this.updateSearchTerm(s,true);- `9 @6 `% \: Q- c0 G% k
else/ S; I$ I* E8 R+ G! s3 K7 X
this.updateSearchTerm(" ",true);/ G) u: j1 I( `& C! Q) t- S7 V$ l
// we manually updated the search field
+ g; B+ g3 Q8 _$ D+ h event.preventDefault();
- Z! I/ F2 k- D5 s }
& N; ?7 H1 w5 \) S3 U* {& u原理:
3 U' H0 K/ \2 L' y* Js是上屏的首個字串,判斷是否英文或符號而決定是否上屏.- d# M) g) A$ p+ Z- Z% y
Bug:
* b" z4 D8 Q) C: N5 p `有時候數字模式會檢測不到首個輸入字,而不會自動打開just type,或是在just tpye的光標會不見了,
: o0 F. ^% J8 |解決方法:手動按1下just type的輸入欄,光標重新出現,之後就可以正常使用
8 K; a# s" ~& j& Z' w. G; D這bug不是經常出現,出現原因也不太清楚,
+ @& Y3 P5 X2 M' M f' ]: n我只是個javascript新手,如果有人有更好的判斷方法,請分享一下.
: N1 j" T: d7 }8 ?" @% B6 k0 j! z* }' G$ T
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?加入我们
×
|