5.1.3:Message
Handlers
メッセージ・ハンドラ
Each message
handler begins with
the on
control structure
followed by the name of the message that this handler
responds to. The handler ends with the end
control structure
and the name of the message. Message handlers look like
this:
メッセージ・ハンドラは必ずコントロール構造である「on」で始まり、その後ろにハンドラが対応するメッセージ名が続いています。ハンドラは必ずコントロール構造である「end」で終わり、その後ろにはメッセージ名が書かれています。メッセージ・ハンドラの例は次の様になります:
on
mouseUp
beep
end
mouseUp
A message handler is executed when the object whose script
contains the handler receives the message. This example
handler responds to the mouseUp
message (see
Messages).
メッセージ・ハンドラは、ハンドラを含むオブジェクトのスクリプトがメッセージを受けとった時に実行されます。この例では、ハンドラはmouseUpメッセージが発生した時に実行されることになります(Messages参照)。
【訳注】上の例では、このハンドラが書かれたオブジェクト(例えばボタン)が、マウスでクリックされ、マウスのボタンが押された後放された時に発生するmouseUpメッセージを受けとって、ビープ音を鳴らすというスクリプトが実行されることになります。