找回密码
 加入我们

QQ登录

只需一步,快速开始

搜索
查看: 1668|回复: 2

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

[复制链接]
发表于 2011-4-20 12:59 | 显示全部楼层 |阅读模式
我是2.1的,嘗試了一下,解決了just type輸入中文時,出現英文首字母的問題.
* l: S8 L' J. O6 w- l  `2 l& Ye.g. 以前拼音輸入"你好"會出現"n你好",修改後只會出現"你好"
7 l' c' P( F. o2 P* x
8 b7 M- K  ]3 i2 y7 W% A/ H' C/ a" {; M  U! r% c" P) p$ D2 {0 o
/usr/lib/luna/system/luna-applauncher/app/controllers/global-search-assistant.js
8 I3 D( N8 z# J1 F7 |; N2 B
2 S" I+ ^0 ?) t. f; u( C原本內容:. K$ G, q- B8 _3 |2 M5 `7 _
                // try to handle the very first key event
8 @1 E5 ]. V$ A                var s;, x! R! J7 s9 K' _' W
                if (Mojo.Char.isPrintableChar(event.keyCode, true) && !event.ctrlKey) {
/ G( k' P' ?( U' N; S                        s = String.fromCharCode(event.keyCode);
  E  e7 [6 G! ], s6 V9 g                }
2 I$ M+ K3 e5 t/ j                if (s && this.searchTerm.length==0 && this.searchPressHoldTerm.length==0) {+ w/ P% f: T2 d+ a  ]8 c
                        // first valid key press event
; W) e- N% c, F                        this.onActivate(s);0 U; ~( v' g) z; _
                        this.updateSearchTerm(s, true);& b8 h' g. c- I; Z! t! R0 J. E
                       
: T& D; M. {; Q$ S                        // we manually updated the search field3 s% p& p" T. a5 u% b0 w
                        event.preventDefault();* r7 ?% _! |, ^: B. `8 F
                }
% i# Z8 V. v' Q: a7 l( F: h修改後內容:
0 s; N  b- s4 f, \  B5 }1 o4 o                // try to handle the very first key event
, A6 Y: H. Y; E5 W& m: _, K& e                var s=/^\w+$/;) D% V# |2 P( j/ m% `
                if (Mojo.Char.isPrintableChar(event.keyCode, true) && !event.ctrlKey) {$ p# Q' e) u: @/ S' K
                        s = String.fromCharCode(event.keyCode);
% l1 E/ v) C1 v) K, V                }2 E" [5 |5 @7 `' ~5 }
                if (s && this.searchTerm.length==0 && this.searchPressHoldTerm.length==0) {! _! b6 W" b. K; F+ C) ]" n3 M
                        // first valid key press event
, c- C% a# v( w9 }4 h                        this.onActivate(s);+ s# u# D$ h* x$ S8 C9 H* d
                        if(!s.test(str))
# K5 p; P% [3 A' ]                                this.updateSearchTerm(s,true);: F8 m7 p! [& m
                        else! v" Q) I7 \" V% |+ T: Z( V
                                this.updateSearchTerm(" ",true);
" g" V& e, a4 f  ?                        // we manually updated the search field
8 N' r( k" w8 B+ a  g9 R                        event.preventDefault();( ^1 D' V3 e4 p$ Z% l, T, R% _
                }6 z! V3 Q  v/ {- }" D* |7 p  N
原理:
" E3 P9 \) s, d9 L+ l( Hs是上屏的首個字串,判斷是否英文或符號而決定是否上屏.
9 q) g  }8 N, bBug:
/ I+ S& o* o) X# k: i, w  q, o有時候數字模式會檢測不到首個輸入字,而不會自動打開just type,或是在just tpye的光標會不見了,6 g  S0 p: V/ q, v! _, A$ T0 K
解決方法:手動按1下just type的輸入欄,光標重新出現,之後就可以正常使用( p; p. w6 v" z( S  e) E% ]# [
這bug不是經常出現,出現原因也不太清楚,' ^" r9 N* l. ~% S8 [
我只是個javascript新手,如果有人有更好的判斷方法,請分享一下.
! `1 ^  F3 B# y; g$ i, g. d, g% c+ E0 _6 J- |$ d" _4 W

本帖子中包含更多资源

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

×
回复

使用道具 举报

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

使用道具 举报

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

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-4-17 02:14 , Processed in 0.240523 second(s), 17 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2025 Discuz! Team.

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