国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網(wǎng)站 > WEB開發(fā) > 正文

26.5.支持IME設(shè)備

2024-04-27 13:52:38
字體:
供稿:網(wǎng)友
26.5.1. 問題
我想分發(fā)使用日文,中文或韓文等多字節(jié)字符的應(yīng)用程序
26.5.2. 解決辦法
使用Capabilities類檢測輸入法編輯器,使用IME類控制如何與Flex應(yīng)用程序交互。
26.5.3. 討論
東方的語言如漢字就是以象形字組成而不是用拉丁字符組成。拉到語言的字符是有限的,可被輕松的映射到鍵盤上。但這方法對于東方語言就不可能,因為這需要成千上萬個鍵盤按鍵。

輸入法編輯器(IMEs)是軟件工具,允許字符由多個按鍵組合而成。IME是運(yùn)行在操作系統(tǒng)級別,在Flash Player外部。

Capabilities類有個屬性叫hasIME,你可以使用它檢測用戶系統(tǒng)是否安裝有IME。使用flash.system.IME對象檢測是否已啟動IME以及設(shè)置了什么轉(zhuǎn)換模式。下面的例子測試IME,如果找到,啟動IME并設(shè)置轉(zhuǎn)換模式:
+展開
-ActionScript
private function detectIME():void
{
if (Capabilities.hasIME == true)
{
output.text = "Your system has an IME installed./n";
if (flash.system.IME.enabled == true)
{
output.text += "Your IME is enabled. and set to " + flash.system.IME.conversionMode;
}
else
{
output.text += "Your IME is disabled/n";
try
{
flash.system.IME.enabled = true;
flash.system.IME.conversionMode = IMEConversionMode.JAPANESE_HIRAGANA;
output.text += "Your IME has been enabled successfully";
}
catch (e:Error)
{
output.text +="Your IME could not be enabled./n"
}
}
}
else output.text = "You do not have an IME installed./n";
}

當(dāng)嘗試創(chuàng)作IME設(shè)置時必須使用try...catch代碼塊,因為如果IME不支持指定設(shè)置就會發(fā)生錯誤。

有時候你可能希望禁用IME,比如某個文本框只輸入數(shù)字。這時你可以在組件獲得焦點(diǎn)時觸發(fā)一個函數(shù)禁用IME,當(dāng)組件失去焦點(diǎn)時重新啟動IME:
+展開
-XML
<mx:Script>
<[CDATA[
private function enableIME(enable:Boolean):void
{
if (Capabilities.hasIME)
{
try
{
flash.system.IME.enabled = enable;
trace("IME " + (enable ? "enable" : "disable"));
}
catch (e:Error)
{
Alert.show("Could not " (enable ? "enable" : "disable") + " IME");
}
}
}
]]>

</mx:Script>
<mx:VBox horizontalCenter="0verticalCenter="0" >
<mx:TextInput id="numericInputfocusIn="enableIME(false)"
focusOut="enableIME(true)" />

<mx:TextInput id="textInput" />
</mx:VBox>
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 太和县| 开封市| 游戏| 米泉市| 翁牛特旗| 尼玛县| 乃东县| 长葛市| 大石桥市| 遂宁市| 工布江达县| 和静县| 沧州市| 太保市| 天峻县| 名山县| 宜都市| 永济市| 木里| 海阳市| 塔城市| 韶山市| 托克逊县| 齐齐哈尔市| 四川省| 平利县| 阳春市| 长宁县| 长寿区| 南岸区| 蒙山县| 岳池县| 丰原市| 长武县| 虞城县| 宁陕县| 曲水县| 彰化市| 庄浪县| 聂拉木县| 聂拉木县|