# ui/uibutton (vanilla-engine 0.4.0)

> https://vanillapunch.com/docs/vanilla-engine/0.4.0/api/ui/uibutton/

버튼. (원본 ui/uibutton.js 의 UIButton, ButtonState)
- 누름 / 뗌 / 취소 / 클릭 / 길게 누름 / 마우스 오버 이벤트와, 누르거나 올렸을 때 색이 변하는 틴트 트랜지션.
- 클릭은 눌렀다가 버튼 영역 안에서 뗄 때만 일어난다. (길게 누름이 발화한 누름은 클릭을 삼킨다)
- 틴트는 원본처럼 호스트 노드와 모든 자손의 Sprite / UIImageView(덮는 색), Paint / Text / UILabel(원래 색 보간)에 건다.
  호스트 노드의 다른 컴포넌트는 tick / 터치 중에 형제로 찾는다. (NodeTree 가 부르는 컴포넌트만 잠깐 꺼낸다)
  원본은 Sprite 가 Paint 를 상속해 getComponents(Paint) 에도 잡힌다. 그래서 스프라이트에는 덮는 색 다음에 원래 색 보간이 한 번 더 걸려
  뒤의 것이 이긴다. 같은 결과를 내려고 러스트 판도 스프라이트(와 UIImageView 의 스프라이트)를 두 번 담는다.
- 원본과 다른 것:
  - 이벤트는 `Box<dyn FnMut(&mut UIButton, &mut ComponentContext)>` 다. 원본 콜백은 버튼만 받는다.
    문맥을 함께 넘겨 콜백에서 다른 노드를 바꾸거나 만들고 지울 수 있게 했다. (클릭 이벤트의 bool 반환은 원본에서도 쓰지 않아 뺐다)
    받은 이벤트는 `Rc<RefCell>` 에 담는다. 이벤트 getter 는 그 Rc 를 돌려주고, 부르는 쪽은 borrow_mut 로 빌려 버튼과 문맥을 넘겨 부른다.
    부르는 동안 같은 이벤트를 다시 부르면(콜백 안에서 fire_click_events 같은) 이미 빌려 있어 건너뛴다.
  - 원본 setInteractable / UIToggleButton.set_is_on 은 그 자리에서 색 대상을 모으고 틴트를 건다. 러스트 판은 노드에 닿을 수 없는 자리라
    다음 tick 에 모으고 건다. (tick 이 매 프레임 틴트를 다시 거므로 보이는 결과는 같다)
  - 제외 컴포넌트는 인스턴스 대신 (노드, 컴포넌트 타입) 으로 정한다: `exclude_component_from_tint::<Paint>`(node_id).
  - setStateEvent(원본도 빈 함수)는 옮기지 않았다.
- attach_to_tree 에서 호스트 노드를 interactable 로 켠다. node_tree.add_component(node_id, UIButton::new()) 로 붙인다.

## UIButtonEvent (type)

버튼 이벤트. (버튼과 문맥을 받는다)

```rust
pub type UIButtonEvent = Box<dyn FnMut(&mut UIButton, &mut ComponentContext)>
```

## UIButton (struct) (Default, Component)

버튼.

예제: 글자가 있는 단추 만들기

```rust
use std::cell::Cell;
use std::rc::Rc;
use vanilla::{ComponentContext, Engine, EngineConfiguration, NodeTree, Paint, Text, TouchKind, UIButton, Vector2};

let engine = Engine::new(EngineConfiguration::new());
let mut node_tree = NodeTree::new();
let root_id = node_tree.get_root_id();
let button_id = node_tree.create_child(root_id, "OkButton");
node_tree[button_id].set_local_position(Vector2::create(200.0, 100.0));
node_tree[button_id].set_content_size(Vector2::create(160.0, 48.0));
node_tree[button_id].add_component(Paint::create_with_color("#3b82f6"));
node_tree[button_id].add_component(Text::create_with_text("OK", 24.0));
let click_count = Rc::new(Cell::new(0));
let click_count_for_event = click_count.clone();
let button = node_tree.add_component(button_id, UIButton::new()).expect("button");
button.set_click_event(Box::new(move |_button: &mut UIButton, _context: &mut ComponentContext| {
	click_count_for_event.set(click_count_for_event.get() + 1);
}));
assert!(node_tree[button_id].is_interactable());

let inside = Vector2::create(210.0, 105.0);
node_tree.dispatch_touch(button_id, &engine, TouchKind::Press, inside);
node_tree.dispatch_touch(button_id, &engine, TouchKind::Release, inside);
assert_eq!(click_count.get(), 1);

let outside = Vector2::create(400.0, 105.0);
node_tree.dispatch_touch(button_id, &engine, TouchKind::Press, inside);
node_tree.dispatch_touch(button_id, &engine, TouchKind::Release, outside);
assert_eq!(click_count.get(), 1);
```

- `pub fn new() -> UIButton` (constructor, since 0.3.2): 생성.
  - 트리에 붙이려면 node_tree.add_component(node_id, UIButton::new()) 를 쓴다. (붙을 때 컨텐트 노드를 만들고 호스트 노드를 interactable 로 켠다)
  - returns UIButton: 이벤트가 없는 새 버튼. (길게 누름 0.5 초, 최소 눌림 0 초, 눌림 틴트 검정 알파 0.3, 오버 틴트 흰색 알파 0.12, 트랜지션 0.3 초)
- `pub fn get_uicontrol(&self) -> &UIControl` (method, since 0.3.2): 품은 컨트롤 반환.
  - returns &UIControl: 품은 UIControl.
- `pub fn get_uicontrol_mut(&mut self) -> &mut UIControl` (method, since 0.3.2): 품은 컨트롤 반환. (변경용)
  - returns &mut UIControl: 품은 UIControl.
- `pub fn get_content(&self) -> Option<NodeId>` (method, since 0.3.2): 컨텐트 노드 핸들.
  - returns Option<NodeId>: 호스트 노드 밑에 만든 컨텐트 노드. 트리에 붙기 전이면 None.
- `pub fn exclude_node_from_tint(&mut self, node_id: NodeId)` (method, since 0.3.2): 트랜지션 대상에서 노드를 제외. (그 노드와 모든 자손의 컴포넌트가 색 대상에서 빠진다)
  - 다음에 색 대상을 모을 때(누름, 오버, 사용 불가)부터 빠진다.
  - `node_id` NodeId: 틴트에서 뺄 노드. (이미 든 노드면 그대로)

  예제: 단추 안의 배지는 틴트하지 않기

  ```rust
  use vanilla::{Color, Engine, EngineConfiguration, NodeTree, Paint, TouchKind, UIButton, Vector2};
  
  let engine = Engine::new(EngineConfiguration::new());
  let mut node_tree = NodeTree::new();
  let root_id = node_tree.get_root_id();
  let button_id = node_tree.create_child(root_id, "Button");
  node_tree[button_id].set_content_size(Vector2::create(100.0, 40.0));
  node_tree[button_id].add_component(Paint::create_with_color(Color::white()));
  let badge_id = node_tree.create_child(button_id, "Badge");
  node_tree[badge_id].add_component(Paint::create_with_color(Color::white()));
  let button = node_tree.add_component(button_id, UIButton::new()).expect("button");
  button.exclude_node_from_tint(badge_id);
  
  node_tree.dispatch_touch(button_id, &engine, TouchKind::Press, Vector2::zero());
  node_tree.tick(&engine, 0.3);
  let button_color = node_tree[button_id].get_component::<Paint>().expect("paint").get_color();
  let badge_color = node_tree[badge_id].get_component::<Paint>().expect("paint").get_color();
  assert!((button_color.red - 0.7).abs() < 0.001);
  assert_eq!(badge_color, Color::white());
  ```

- `pub fn exclude_component_from_tint<T: Component + 'static>(&mut self, node_id: NodeId)` (method, since 0.3.2): 트랜지션 대상에서 그 노드의 T 타입 컴포넌트만 제외. (원본은 컴포넌트 인스턴스를 받는다)
  - 다음에 색 대상을 모을 때부터 빠진다. 자손 노드의 T 는 빠지지 않는다.
  - `node_id` NodeId: T 타입 컴포넌트를 뺄 노드. (호스트 노드나 그 자손)

  예제: 바탕 Paint 는 그대로 두고 글자만 틴트하기

  ```rust
  use vanilla::{Color, Engine, EngineConfiguration, NodeTree, Paint, Text, TouchKind, UIButton, Vector2};
  
  let engine = Engine::new(EngineConfiguration::new());
  let mut node_tree = NodeTree::new();
  let root_id = node_tree.get_root_id();
  let button_id = node_tree.create_child(root_id, "Button");
  node_tree[button_id].set_content_size(Vector2::create(100.0, 40.0));
  node_tree[button_id].add_component(Paint::create_with_color(Color::white()));
  node_tree[button_id].add_component(Text::create_with_text("OK", 20.0));
  let button = node_tree.add_component(button_id, UIButton::new()).expect("button");
  button.exclude_component_from_tint::<Paint>(button_id);
  
  node_tree.dispatch_touch(button_id, &engine, TouchKind::Press, Vector2::zero());
  node_tree.tick(&engine, 0.3);
  let paint_color = node_tree[button_id].get_component::<Paint>().expect("paint").get_color();
  let text_color = node_tree[button_id].get_component::<Text>().expect("text").get_text_color();
  assert_eq!(paint_color, Color::white());
  assert!(text_color.red < 1.0);
  ```

- `pub fn clear_tint_exclusions(&mut self)` (method, since 0.3.2): 제외 목록 비우기.
- `pub fn fire_click_events(&mut self, context: &mut ComponentContext)` (method, since 0.4.0): 클릭 알림만 부르기. (누르지 않고 클릭이 난 것처럼 Clicked, Click 차례로, UIHitArea 가 넓힌 자리의 클릭을 넘길 때)
  - 지금 부르는 중인 이벤트는 건너뛴다. (클릭됨 이벤트 안에서 부르면 클릭만 한 번 더 불린다)
  - `context` &mut ComponentContext: 이 버튼 노드의 문맥. (이벤트에 그대로 넘긴다)

  예제: 다른 단추의 클릭을 이 단추로 넘기기

  ```rust
  use std::cell::Cell;
  use std::rc::Rc;
  use vanilla::{ComponentContext, Engine, EngineConfiguration, NodeTree, TouchKind, UIButton, Vector2};
  
  let engine = Engine::new(EngineConfiguration::new());
  let mut node_tree = NodeTree::new();
  let root_id = node_tree.get_root_id();
  let button_id = node_tree.create_child(root_id, "Button");
  let click_count = Rc::new(Cell::new(0));
  let click_count_for_event = click_count.clone();
  let button = node_tree.add_component(button_id, UIButton::new()).expect("button");
  button.set_click_event(Box::new(move |_button: &mut UIButton, _context: &mut ComponentContext| {
  	click_count_for_event.set(click_count_for_event.get() + 1);
  }));
  
  let relay_id = node_tree.create_child(root_id, "Relay");
  node_tree[relay_id].set_content_size(Vector2::create(40.0, 40.0));
  let relay_button = node_tree.add_component(relay_id, UIButton::new()).expect("relay");
  relay_button.set_click_event(Box::new(move |_relay_button: &mut UIButton, context: &mut ComponentContext| {
  	context.with_component_mut::<UIButton, ()>(button_id, |button, button_context| {
  		button.fire_click_events(button_context);
  	});
  }));
  node_tree.dispatch_touch(relay_id, &engine, TouchKind::Press, Vector2::zero());
  node_tree.dispatch_touch(relay_id, &engine, TouchKind::Release, Vector2::zero());
  assert_eq!(click_count.get(), 1);
  ```

- `pub fn set_button_state(&mut self, button_state: ButtonState)` (method, since 0.3.2): 버튼 상태 설정.
  - `button_state` ButtonState: 새 상태. (이벤트를 부르거나 틴트를 다시 걸지 않는다)
- `pub fn get_button_state(&self) -> ButtonState` (method, since 0.3.2): 버튼 상태 반환.
  - returns ButtonState: 지금 상태.
- `pub fn set_long_pressed_event(&mut self, long_pressed_event: UIButtonEvent)` (method, since 0.3.2): 길게 누름 이벤트 설정. (임계 시간을 넘기면 한 번 알리고, 그 누름의 클릭은 삼킨다)
  - 임계 시간은 set_long_press_seconds 로 정한다. 시간은 tick 에서 센다.
  - `long_pressed_event` UIButtonEvent: 길게 누름이 되었을 때 부를 함수. (버튼과 문맥을 받는다)

  예제: 길게 누르면 지우고 짧게 누르면 열기

  ```rust
  use std::cell::Cell;
  use std::rc::Rc;
  use vanilla::{ComponentContext, Engine, EngineConfiguration, NodeTree, TouchKind, UIButton, Vector2};
  
  let engine = Engine::new(EngineConfiguration::new());
  let mut node_tree = NodeTree::new();
  let root_id = node_tree.get_root_id();
  let button_id = node_tree.create_child(root_id, "Slot");
  node_tree[button_id].set_content_size(Vector2::create(80.0, 80.0));
  let delete_count = Rc::new(Cell::new(0));
  let open_count = Rc::new(Cell::new(0));
  let delete_count_for_event = delete_count.clone();
  let open_count_for_event = open_count.clone();
  let button = node_tree.add_component(button_id, UIButton::new()).expect("button");
  button.set_long_press_seconds(0.5);
  button.set_long_pressed_event(Box::new(move |_button: &mut UIButton, _context: &mut ComponentContext| {
  	delete_count_for_event.set(delete_count_for_event.get() + 1);
  }));
  button.set_click_event(Box::new(move |_button: &mut UIButton, _context: &mut ComponentContext| {
  	open_count_for_event.set(open_count_for_event.get() + 1);
  }));
  
  node_tree.dispatch_touch(button_id, &engine, TouchKind::Press, Vector2::zero());
  node_tree.tick(&engine, 0.3);
  node_tree.tick(&engine, 0.3);
  node_tree.dispatch_touch(button_id, &engine, TouchKind::Release, Vector2::zero());
  assert_eq!(delete_count.get(), 1);
  assert_eq!(open_count.get(), 0);
  
  node_tree.dispatch_touch(button_id, &engine, TouchKind::Press, Vector2::zero());
  node_tree.tick(&engine, 0.1);
  node_tree.dispatch_touch(button_id, &engine, TouchKind::Release, Vector2::zero());
  assert_eq!(delete_count.get(), 1);
  assert_eq!(open_count.get(), 1);
  ```

- `pub fn get_pressed_elapsed_seconds(&self) -> f64` (method, since 0.3.2): 이번 누름이 이어진 시간 반환. (누르고 있지 않으면 0. 게이지 연출용)
  - returns f64: 누른 뒤 지난 초. (tick 에서 쌓는다, 누르고 있지 않으면 0)
- `pub fn set_long_press_seconds(&mut self, long_press_seconds: f64)` (method, since 0.3.2): 길게 누름 판정 시간 설정. (초)
  - `long_press_seconds` f64: 누름이 이만큼 이어지면 길게 누름으로 본다. (초, 기본 0.5)
- `pub fn get_long_press_seconds(&self) -> f64` (method, since 0.3.2): 길게 누름 판정 시간 반환.
  - returns f64: 길게 누름 판정 시간. (초)
- `pub fn set_minimum_pressed_seconds(&mut self, minimum_pressed_seconds: f64)` (method, since 0.3.2): 최소 눌림 표시 시간 설정. (짧게 눌러도 이 시간만큼 눌린 모습을 보인 뒤 클릭한다. 기본 0 = 바로)
  - 시간을 못 채운 뗌은 미뤄 두었다가 tick 에서 처리하고, 그동안 상태는 Pressed 다.
  - `minimum_pressed_seconds` f64: 최소 눌림 표시 시간. (초, 0 보다 작으면 0)

  예제: 톡 쳐도 0.2 초는 눌린 모습 보이기

  ```rust
  use std::cell::Cell;
  use std::rc::Rc;
  use vanilla::{ButtonState, ComponentContext, Engine, EngineConfiguration, NodeTree, TouchKind, UIButton, Vector2};
  
  let engine = Engine::new(EngineConfiguration::new());
  let mut node_tree = NodeTree::new();
  let root_id = node_tree.get_root_id();
  let button_id = node_tree.create_child(root_id, "Button");
  node_tree[button_id].set_content_size(Vector2::create(100.0, 40.0));
  let click_count = Rc::new(Cell::new(0));
  let click_count_for_event = click_count.clone();
  let button = node_tree.add_component(button_id, UIButton::new()).expect("button");
  button.set_minimum_pressed_seconds(0.2);
  button.set_click_event(Box::new(move |_button: &mut UIButton, _context: &mut ComponentContext| {
  	click_count_for_event.set(click_count_for_event.get() + 1);
  }));
  
  node_tree.dispatch_touch(button_id, &engine, TouchKind::Press, Vector2::zero());
  node_tree.dispatch_touch(button_id, &engine, TouchKind::Release, Vector2::zero());
  let button_state = node_tree[button_id].get_component::<UIButton>().expect("button").get_button_state();
  assert_eq!(button_state, ButtonState::Pressed);
  assert_eq!(click_count.get(), 0);
  node_tree.tick(&engine, 0.25);
  assert_eq!(click_count.get(), 1);
  ```

- `pub fn get_minimum_pressed_seconds(&self) -> f64` (method, since 0.3.2): 최소 눌림 표시 시간 반환.
  - returns f64: 최소 눌림 표시 시간. (초, 기본 0)
- `pub fn set_click_event(&mut self, click_event: UIButtonEvent)` (method, since 0.3.2): 클릭 이벤트 설정. (클릭됨 이벤트 다음에 불린다)
  - 클릭은 눌렀다가 버튼 영역 안에서 뗄 때만 난다. 길게 누름이 발화한 누름은 클릭을 삼킨다.
  - `click_event` UIButtonEvent: 클릭할 때 부를 함수. (버튼과 문맥을 받는다, 문맥으로 다른 노드를 바꿀 수 있다)

  예제: 닫기 단추를 누르면 판 숨기기

  ```rust
  use vanilla::{ComponentContext, Engine, EngineConfiguration, NodeTree, TouchKind, UIButton, Vector2};
  
  let engine = Engine::new(EngineConfiguration::new());
  let mut node_tree = NodeTree::new();
  let root_id = node_tree.get_root_id();
  let panel_id = node_tree.create_child(root_id, "Panel");
  let close_id = node_tree.create_child(root_id, "Close");
  node_tree[close_id].set_content_size(Vector2::create(40.0, 40.0));
  let close_button = node_tree.add_component(close_id, UIButton::new()).expect("button");
  close_button.set_click_event(Box::new(move |_button: &mut UIButton, context: &mut ComponentContext| {
  	context.get_node_tree_mut()[panel_id].set_visible(false);
  }));
  
  node_tree.dispatch_touch(close_id, &engine, TouchKind::Press, Vector2::zero());
  node_tree.dispatch_touch(close_id, &engine, TouchKind::Release, Vector2::zero());
  assert!(!node_tree[panel_id].is_visible());
  ```

- `pub fn get_click_event(&self) -> Option<Rc<RefCell<UIButtonEvent>>>` (method, since 0.4.0): 클릭 이벤트 반환. (부를 때는 borrow_mut 로 빌린다)
  - returns Option<Rc<RefCell<UIButtonEvent>>>: 건 클릭 이벤트. 걸지 않았으면 None.

  예제: 누르는 순간 클릭 이벤트를 꺼내 부르기

  ```rust
  use std::cell::Cell;
  use std::rc::Rc;
  use vanilla::{ComponentContext, Engine, EngineConfiguration, NodeTree, TouchKind, UIButton, Vector2};
  
  let engine = Engine::new(EngineConfiguration::new());
  let mut node_tree = NodeTree::new();
  let root_id = node_tree.get_root_id();
  let button_id = node_tree.create_child(root_id, "Button");
  let click_count = Rc::new(Cell::new(0));
  let click_count_for_event = click_count.clone();
  let button = node_tree.add_component(button_id, UIButton::new()).expect("button");
  assert!(button.get_click_event().is_none());
  button.set_click_event(Box::new(move |_button: &mut UIButton, _context: &mut ComponentContext| {
  	click_count_for_event.set(click_count_for_event.get() + 1);
  }));
  button.set_pressed_event(Box::new(|button: &mut UIButton, context: &mut ComponentContext| {
  	if let Some(click_event) = button.get_click_event() {
  		(*click_event.borrow_mut())(button, context);
  	}
  }));
  
  node_tree.dispatch_touch(button_id, &engine, TouchKind::Press, Vector2::zero());
  assert_eq!(click_count.get(), 1);
  ```

- `pub fn set_pressed_event(&mut self, pressed_event: UIButtonEvent)` (method, since 0.3.2): 누름 이벤트 설정.
  - `pressed_event` UIButtonEvent: 누를 때 부를 함수. (버튼과 문맥을 받는다, 누를 수 없으면 불리지 않는다)
- `pub fn get_pressed_event(&self) -> Option<Rc<RefCell<UIButtonEvent>>>` (method, since 0.4.0): 누름 이벤트 반환. (부를 때는 borrow_mut 로 빌린다)
  - returns Option<Rc<RefCell<UIButtonEvent>>>: 건 누름 이벤트. 걸지 않았으면 None.
- `pub fn set_released_event(&mut self, released_event: UIButtonEvent)` (method, since 0.3.2): 뗌 이벤트 설정. (영역 밖에서 떼도 불린다)
  - `released_event` UIButtonEvent: 뗄 때 부를 함수. (버튼과 문맥을 받는다, 클릭됨, 클릭 이벤트보다 먼저 불리고 취소에는 불리지 않는다)
- `pub fn get_released_event(&self) -> Option<Rc<RefCell<UIButtonEvent>>>` (method, since 0.4.0): 뗌 이벤트 반환. (부를 때는 borrow_mut 로 빌린다)
  - returns Option<Rc<RefCell<UIButtonEvent>>>: 건 뗌 이벤트. 걸지 않았으면 None.
- `pub fn set_clicked_event(&mut self, clicked_event: UIButtonEvent)` (method, since 0.3.2): 클릭됨 이벤트 설정.
  - `clicked_event` UIButtonEvent: 클릭할 때 클릭 이벤트보다 먼저 부를 함수. (버튼과 문맥을 받는다)
- `pub fn get_clicked_event(&self) -> Option<Rc<RefCell<UIButtonEvent>>>` (method, since 0.4.0): 클릭됨 이벤트 반환. (부를 때는 borrow_mut 로 빌린다)
  - returns Option<Rc<RefCell<UIButtonEvent>>>: 건 클릭됨 이벤트. 걸지 않았으면 None.
- `pub fn set_hover_tint_color(&mut self, color: impl Into<Color>)` (method, since 0.3.2): 오버 틴트 색 설정.
  - `color` impl Into<Color>: 마우스를 올렸을 때 덮거나 섞을 색. (알파가 세기, 기본 흰색 알파 0.12)
- `pub fn get_hover_tint_color(&self) -> Color` (method, since 0.3.2): 오버 틴트 색 반환.
  - returns Color: 오버 틴트 색.
- `pub fn set_hover_event(&mut self, hover_event: UIButtonEvent)` (method, since 0.3.2): 오버 진입 이벤트 설정.
  - `hover_event` UIButtonEvent: 마우스가 버튼 위로 들어올 때 한 번 부를 함수. (버튼과 문맥을 받는다)
- `pub fn get_hover_event(&self) -> Option<Rc<RefCell<UIButtonEvent>>>` (method, since 0.4.0): 오버 진입 이벤트 반환. (부를 때는 borrow_mut 로 빌린다)
  - returns Option<Rc<RefCell<UIButtonEvent>>>: 건 오버 진입 이벤트. 걸지 않았으면 None.
- `pub fn set_pressed_tint_color(&mut self, color: impl Into<Color>)` (method, since 0.3.2): 눌림 틴트 색 설정.
  - `color` impl Into<Color>: 누를 때 덮거나 섞을 색. (알파가 세기, 기본 검정 알파 0.3)
- `pub fn get_pressed_tint_color(&self) -> Color` (method, since 0.3.2): 눌림 틴트 색 반환.
  - returns Color: 눌림 틴트 색.
- `pub fn set_transition_duration(&mut self, transition_duration: f64)` (method, since 0.3.2): 트랜지션 시간 설정. (초)
  - `transition_duration` f64: 틴트가 끝까지 차오르거나 빠지는 시간. (초, 기본 0.3)
- `pub fn get_transition_duration(&self) -> f64` (method, since 0.3.2): 트랜지션 시간 반환.
  - returns f64: 트랜지션 시간. (초)
- `pub fn set_interactable(&mut self, is_interactable: bool)` (method, since 0.3.2): 사용 가능 설정. (끄면 다음 tick 에 색 대상을 모아 어두운 틴트를 건다)
  - `is_interactable` bool: 누를 수 있게 하려면 true. (끄면 상태가 Disabled, 켜면 Normal, 지금과 같으면 그대로)
- `pub fn get_interactable(&self) -> bool` (method, since 0.3.2): 사용 가능 여부.
  - returns bool: 누를 수 있으면 true. (기본 true)

## ButtonState (enum) (Clone, Copy, Debug, PartialEq, Eq, crate::core::reflection::ToReflectValue)

버튼 상태.

- `Normal`: 보통. (누르지도 올리지도 않음)
- `Hover`: 마우스를 올려 둔 상태.
- `Pressed`: 누르고 있는 상태. (최소 눌림 시간을 채우려고 뗌을 미루는 동안도)
- `Released`: 뗌을 처리하는 중. (뗌, 클릭 이벤트를 부르는 동안만이고 끝나면 Normal)
- `Disabled`: 누를 수 없는 상태. (set_interactable(false))
