2006-04-08

상호작용 (display dialog, display alert)

display dialog

display dialog "Hello, Wolrd!"

display dialog는 메세지를 전달하고, 그에 대한 대답을 받을 수 있습니다.


여기서 설명하지 않은 속성들은 Standart Additions의 사전을 참고하세요.
set theResult to text returned of (display dialog "enter a word" default answer "")
display dialog "you entered \"" & theResult & "\""

default answer를 이용하면 사용자로부터 문장이나 숫자를 대답으로 받을 수도 있습니다.
set favoriteFruit to display dialog "which is your favorite?" buttons {"apple", "orange", "mango"} default button "apple"
display dialog "your favorite fruit is " & button returned of favoriteFruit & "!"

set favoriteCar to button returned of (display dialog "which is your car?" buttons {"sonata", "matiz", "bmw"} default button 2)
display dialog "your favorite car is " & favoriteCar & "!"

buttons을 이용하면 다양한 선택을 제공할 수 있습니다. 안타깝게도 dialog box에서는 버튼을 최대 3개까지만 지원합니다. 4개 이상의 선택이 필요하다면 choose from list를 이용하거나, XCode를 이용해 GUI를 구현해야 합니다. default button은 숫자나 버튼 이름으로 지정할 수 있습니다.
display dialog "stop!" with icon 1
display dialog "notice" with icon note
dialog box에 icon을 삽입할 수 있습니다. stop, note, caution 3가지 icon을 지원하며, icon 이름 대신 번호로 지칭할 수 있습니다.
display dialog "stop!" default answer "why?" with icon caution giving up after 10 with hidden answer




display alert

display dialog는 사용자에게 승인과 취소라는 두 가지 선택을 주지만, display alert은 그저 사용자에게 통보만 할 뿐입니다. 그렇지만 buttons라는 속성을 이용하면 display dialog와 마찬가지로 최대 3개까지의 버튼을 만들 수 있습니다.
display alert "critical alert!!" message "심각한 문제가 발생했습니다!" as critical buttons {"탈출", "자폭", "해결책"} default button 1 cancel button "자폭"

0 Comments:

댓글 쓰기

<< Home