キーボードイベントをのぞき見したいのですが、のドキュメントによるとSensor
、イベントをキューから削除せずにこれを行うことができますがpeekKeyboardEvent
、うまくいかないようです。
これは機能します:
"Show that a single event can be checked multiple times"
Transcript clear; show: 'Type something... '; flush.
(Delay forSeconds: 2) wait.
5 timesRepeat: [
Transcript show: (Sensor peekEvent); cr
]
出力:
Type something... #(2 48243801 5 2 8 0 0 1)
#(2 48243801 5 2 8 0 0 1)
#(2 48243801 5 2 8 0 0 1)
#(2 48243801 5 2 8 0 0 1)
#(2 48243801 5 2 8 0 0 1)
しかし、これはしません:
"Show that a single keyboard event can be checked multiple times"
Transcript clear; show: 'Type something... '; flush.
(Delay forSeconds: 2) wait.
5 timesRepeat: [
Transcript show: (Sensor peekKeyboardEvent); cr
]
出力:
Type something... #(2 48205144 97 0 0 97 0 1)
nil
nil
nil
nil
Transcript flush
さらなる質問:出力がすぐに表示されないのはなぜですか? スクリプトが実行された後にのみ表示されます。