← 수업 제작 도구
홈 › Components › Action Button (행동 버튼) › 화면 8

화면 8. Action Button.disabled [sink]

원본: Computation Layer 문서(Action Button (행동 버튼)) · Try It (원본 화면)

화면 번호8 / 12
문서 항목 설명 (원문)disabled Sets a Boolean that determines when the action button is disabled or enabled. (When it's disabled, we gray out the button and make it unpressable.)

1. 화면 캡처 (빨간 번호 = 아래 표의 번호)

화면 8 캡처

화면에 적힌 영어 문구(원문):

2. CL이 입력된 곳

코드 안의 회색 줄은 원문 영어 주석이고, 파란 줄은 그 영어 주석의 번역이며, 연분홍 줄은 코드가 하는 일의 설명이다.

번호이름종류CL 코드 원문, 번역, 설명
1레이블 없는 메모메모
# This variable "threats" conditionally stores a threat based
# on the number of times the "beCarefulButton" has been pressed.
# (The "\n\n" creates two line breaks before the threat.)
▷ 이 변수 "threats"는 "beCarefulButton"이 눌린 횟수에 따라 협박 문구 하나를 조건에 맞게 저장한다. ("\n\n"은 협박 문구 앞에 줄바꿈 두 번을 만든다.)

threats = 

	when beCarefulButton.pressCount = 1 "\n\nI'm serious."
    when beCarefulButton.pressCount = 2 "\n\nAre YOU serious?"
    when beCarefulButton.pressCount = 3 "\n\nOkay, this is happening."
    when beCarefulButton.pressCount = 4 "\n\nOne more press and it's lights-out time."
    when beCarefulButton.pressCount = 5 "\n\nGood night, pal."
    otherwise ""
▶ 변수 threats는 beCarefulButton이 눌린 횟수가 1이면 "\n\nI'm serious."(진심이다.), 2이면 "\n\nAre YOU serious?"(너야말로 진심인가?), 3이면 "\n\nOkay, this is happening."(좋아, 시작한다.), 4이면 "\n\nOne more press and it's lights-out time."(한 번만 더 누르면 불이 꺼질 시간이다.), 5이면 "\n\nGood night, pal."(잘 자시오, 친구.), 그 밖에는 빈 글자로 한다.
pressCount는 행동 버튼이 눌린 횟수를 알려 주고, when은 조건을 차례로 확인해 처음 맞는 값을 쓴다.
# We will display this content in the note and we're also injecting # whatever threat is stored in "threats". ▷ 이 내용을 메모에 표시하고, "threats"에 저장된 협박 문구도 함께 끼워 넣는다. content: "Press this button five times and I'll disable it. I swear I'll do it. Do not doubt me on this one thing.${threats}" ▶ 메모의 내용(content)은 "Press this button five times and I'll disable it."(이 버튼을 다섯 번 누르면 비활성화하겠다.), "I swear I'll do it."(맹세코 하겠다.), "Do not doubt me on this one thing."(이것만은 나를 의심하지 마시오.)이 각각 빈 줄로 나뉜 글에 이어 threats의 값(${threats})을 붙인 글로 한다.
이 글은 content: 다음 줄부터 마지막 줄까지 하나로 이어진 글이다. ${ }는 글자 안에 변수의 값을 끼워 넣는 표기이고, 마지막 줄 끝의 ${threats} 자리에 threats의 값이 들어간다. content는 메모에 직접 적은 글을 덮어쓴다. 버튼을 누른 횟수에 따라 메모 끝의 협박 문구가 다음 것으로 바뀐다.
2beCarefulButton행동 버튼
# When the button named "beCarefulButton" is pressed for the fifth time
# this button will become disabled.
▷ "beCarefulButton"이라는 버튼이 다섯 번째로 눌리면 이 버튼은 비활성화된다.

disabled: beCarefulButton.pressCount = 5
▶ 행동 버튼의 비활성화 조건(disabled)은 beCarefulButton이 눌린 횟수가 5와 같은지 비교한 결과(beCarefulButton.pressCount = 5)로 한다.
disabled가 참이면 버튼이 회색이 되고 누를 수 없으며, pressCount는 행동 버튼이 눌린 횟수를 알려 준다.