みんなAdobe Flash(現 Animate)というともう死んだかのように言う輩が多いけども、弊社ではiOS & Android モックアップやらプロトタイピング、簡易アプリなど、まだまだ活躍の場は多い。
最近だとタッチディスプレイなどのコンテンツ制作も多くて、そこで入力をさせたいって要望もあるんだけど、これで困ったのが普通のやり方だとソフトウェアキーボード(software keyboard)が出てくれない。
結論からいうと出せるんだけど、やり方がなるほどーって感じだったのでご紹介。
要点としては、
- AIRアプリで拡張デスクトップを指定すること
- ネイティブインストーラ形式にすること
- NativeProcessでソフトウェアキーボードを直接呼び出すこと
となる。
情報元は安定のStackoverflow
http://stackoverflow.com/questions/24364920/could-flash-air-desktop-open-onscreen-keyboard-on-windows
一応テストコードは以下
package {
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.FocusEvent;
import flash.display.InteractiveObject;
import flash.text.TextFieldType;
import flash.text.TextField;
import flash.desktop.NativeProcess;
import flash.desktop.NativeProcessStartupInfo;
import flash.filesystem.File;
public class Test extends MovieClip {
private var textField:TextField = new TextField();
public function Test() {
textField.y = this.stage.stageHeight - 201;
textField.width = this.stage.stageWidth;
textField.height = 200;
textField.type = TextFieldType.INPUT;
textField.border = true;
textField.wordWrap = true;
textField.multiline = true;
this.addChild( textField );
this.stage.addEventListener(FocusEvent.FOCUS_IN,focusIn);
}
private function focusIn(e:FocusEvent):void {
trace("focusIn");
this.exec();
}
private function exec():void {
var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
var file:File = new File("C:\\Windows\\System32\\cmd.exe");
nativeProcessStartupInfo.executable = file;
var v : Vector.<String> = new Vector.<String>();
v.push("start C:/PROGRA~1/COMMON~1/MICROS~1/ink/TabTip.exe");
var process = new NativeProcess();
process.start(nativeProcessStartupInfo);
process.standardInput.writeUTFBytes(v + "\n");
}
}
}