|
我是2.1的,嘗試了一下,解決了just type輸入中文時,出現英文首字母的問題.' Y# C+ C' o& ], L% j0 F4 p$ L2 A: J6 B
e.g. 以前拼音輸入"你好"會出現"n你好",修改後只會出現"你好"
- E$ \3 d2 n5 t, }8 `5 f* E# H: o- |# Z4 s, z4 } ~# v
; ]* @- Y2 G0 l* O" V- s/usr/lib/luna/system/luna-applauncher/app/controllers/global-search-assistant.js
; J3 g+ U# E* k
' K: A( m4 e, E% p h! G原本內容:
, F l) w3 u8 r& `; x, n( p! z // try to handle the very first key event* p, ]9 t t+ l
var s;( \. a% E/ g' O7 p6 f# t( m8 y) C
if (Mojo.Char.isPrintableChar(event.keyCode, true) && !event.ctrlKey) {
' {1 I- A6 w' A. a9 s/ M1 e. @ s = String.fromCharCode(event.keyCode);' |6 V3 [" z5 `$ h: x- b3 M
}
1 g+ E! d5 ~6 |% t if (s && this.searchTerm.length==0 && this.searchPressHoldTerm.length==0) {
- ~9 B* |3 i# Q // first valid key press event' }/ u, b- j0 m1 W
this.onActivate(s);4 p5 {( x8 J2 V4 W- u1 n
this.updateSearchTerm(s, true);
; q; q0 H- P3 N% q. d( {
( t' F/ e+ M1 |2 ^: ]' V // we manually updated the search field0 w) s5 x6 G; V1 i
event.preventDefault();
5 @+ {4 G$ e/ g4 d4 R5 z& K/ z }. [! l1 k- K8 z% O Q
修改後內容:. f p8 ~5 U: E! j8 g. p
// try to handle the very first key event' K: b$ Z& C* q. Y: Q1 G! s
var s=/^\w+$/;8 ^- E& V! ^8 ]2 Q4 c1 c4 X
if (Mojo.Char.isPrintableChar(event.keyCode, true) && !event.ctrlKey) {4 I. g1 N8 }3 b# G# l9 _
s = String.fromCharCode(event.keyCode);0 l7 h# [, C! m+ @
}! c. [ a! o% j8 c& w# T+ R
if (s && this.searchTerm.length==0 && this.searchPressHoldTerm.length==0) {5 Y" G x: y! z# c0 h
// first valid key press event
0 Y2 P S9 Q$ c, H( `6 P this.onActivate(s);4 }, k Y$ _* L1 O0 o9 m
if(!s.test(str))
' {0 l& B# e5 S- R this.updateSearchTerm(s,true);
; N/ F: ~1 K- u' s$ E else
4 z7 m' e7 ? Z% T5 W6 _/ D this.updateSearchTerm(" ",true);
9 @* c- g, e$ z/ p- U // we manually updated the search field
& f/ V% v. S. e( N event.preventDefault();
2 S& Y% K# g6 J2 e, e }! q9 e' w$ l" P" ?. p& x: E/ Q$ M% _
原理:* e+ O0 J9 E, N6 o
s是上屏的首個字串,判斷是否英文或符號而決定是否上屏.
# r( A$ k3 z; D2 G A1 L5 \% S2 H# QBug:7 _7 J7 q" ~% f& E/ `7 A1 Z' s! x7 _
有時候數字模式會檢測不到首個輸入字,而不會自動打開just type,或是在just tpye的光標會不見了,3 ^" _# Y3 \7 T. Z% n) c
解決方法:手動按1下just type的輸入欄,光標重新出現,之後就可以正常使用
0 A9 G6 E$ B7 v2 L* l0 t& j這bug不是經常出現,出現原因也不太清楚,$ x. Y) d' }$ H* F
我只是個javascript新手,如果有人有更好的判斷方法,請分享一下.- V: a$ f* T! C. E$ V
/ f: n" `7 A7 U: B, e5 W
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?加入我们
×
|