找回密码
 加入我们

QQ登录

只需一步,快速开始

搜索
查看: 1634|回复: 2

[软件及汉化] 解決just type中文輸入,首字母問題

[复制链接]
发表于 2011-4-20 12:59 | 显示全部楼层 |阅读模式
我是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

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入我们

×
回复

使用道具 举报

发表于 2011-4-20 13:13 | 显示全部楼层
谢谢分享,越来越多的人加入到开发自定义的行列中了!
回复 支持 反对

使用道具 举报

发表于 2011-4-20 14:31 | 显示全部楼层
还在用qq云啊。试试wbee吧
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 加入我们

本版积分规则

QQ|Archiver|手机版|小黑屋|吹友吧 ( 京ICP备05078561号 )

GMT+8, 2024-9-21 14:48 , Processed in 0.286080 second(s), 16 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表