본문으로 건너뛰기
Skillpedia
웹사이트 및 UI (프런트엔드)48k · #5141

makepad-2-0-events

하는 일

이 가이드는 Makepad 2.0이 클릭과 입력 같은 사용자 상호작용을 어떻게 처리하는지 설명합니다. 이런 동작을 코드의 함수와 연결해 프로그램이 올바르게 반응하도록 하는 방법을 보여 줍니다.

사용하는 경우

  • ✓버튼이 동작을 수행하게 하고 싶을 때.
  • ✓텍스트 필드에서 Enter를 누를 때 프로그램이 반응해야 할 때.
  • ✓업데이트하거나 삭제할 수 있는 항목 목록을 만들 때.

스킬 링크

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/makepad-2-0-events/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/makepad-2-0-events/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“버튼을 누르면 텍스트 필드의 정보를 저장하게 하려면 어떻게 하나요?”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

Makepad는 이벤트를 처리하는 두 곳을 사용합니다. 하나는 시각 코드 안(Splash)이고, 다른 하나는 더 복잡한 Rust입니다. 직접적인 동작에는 시각 코드가 더 간단하고, 무거운 작업은 Rust가 맡습니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Limitations

  • Verify against current Makepad 2.0 docs; upstream APIs change frequently.
  • Do not run bundled scripts without explicit user approval.

When to Use

  • Use when this upstream workflow matches the user's stated goal.
  • Use when the task requires the procedures documented in this skill.

Makepad 2.0 Event & Action System

Overview

Makepad 2.0 uses a two-layer event system:

  1. Splash Layer -- Inline event handlers written directly in script_mod! Splash code (on_click, on_render, on_return, on_startup). These handle UI interactions declaratively inside the script, close to the widget definitions.

  2. Rust Layer -- The MatchEvent trait with handle_actions, handle_timer, handle_http_response, etc. These handle business logic, external I/O, and anything that needs full Rust power.

Both layers communicate through two bridge macros:

  • script_eval!(cx, { ... }) -- Execute Splash code from Rust (update state, trigger renders)
  • script_apply_eval!(cx, widget_ref, { ... }) -- Patch widget properties from Rust at runtime

1. Splash Inline Event Handlers

Event handlers are attached directly to widgets inside script_mod! blocks. They use closure syntax with || for no arguments or |arg| for callbacks that receive a value.

on_click -- Button/widget click

Fires when the user clicks a button or clickable widget. No arguments for plain buttons, or |checked| for CheckBox which passes the new boolean state.

// Plain button click
add_button := Button{
    text: "Add"
    on_click: ||{
        let text = ui.todo_input.text()
        if text != "" {
            add_todo(text, "")
            ui.todo_input.set_text("")
        }
    }
}

// CheckBox click with checked state argument
check.on_click: |checked| toggle_todo(i, checked)

// Inline delete with closure capturing loop variable
delete.on_click: || delete_todo(i)

// Calling another widget's click programmatically
clear_done := ButtonFlatter{
    text: "Clear completed"
    on_click: ||{
        todos.retain(|todo| !todo.done)
        ui.todo_list.render()
    }
}

on_render -- Dynamic rendering

Fires when .render() is called on the target view. This is the primary mechanism for dynamic content. The body replaces the previous draw content of the view.

main_view := View{
    width: Fill
    height: Fill
    on_render: ||{
        counter_label := Label{
            text: "Count: " + state.counter
            draw_text.text_style.font_size: 24
        }
    }
}

// List rendering with for loop and per-item event handlers
todo_list := ScrollYView{
    width: Fill height: Fill
    new_batch: true
    on_render: ||{
        if todos.len() == 0
            EmptyState{}
        else for i, todo in todos {
            TodoItem{
                label.text: todo.text
                check.active: todo.done
                check.on_click: |checked| toggle_todo(i, checked)
                delete.on_click: || delete_todo(i)
            }
        }
    }
    EmptyState{}
}

Key point: on_render is NOT called automatically. You must call ui.widget_name.render() to trigger it. The new_batch: true property on a view tells the system to clear previous draw content before re-rendering.

on_return -- TextInput enter key

Fires when the user presses Enter/Return inside a TextInput. Commonly used to submit forms.

todo_input := TextInput{
    width: Fill height: 9. * theme.space_1
    empty_text: "What needs to be done?"
    on_return: || ui.add_button.on_click()
}

on_startup -- App startup

Fires once when the application starts. Defined at the Root level. Commonly used to trigger initial renders.

ui: Root{
    on_startup: ||{
        ui.main_view.render()
    }
    main_window := Window{
        // ...
    }
}

Event handler capabilities

Inside event handlers you can:

  • Call Splash functions: add_todo(text, "dev")
  • Read widget values: let text = ui.todo_input.text()
  • Set widget values: ui.todo_input.set_text("")
  • Trigger re-renders: ui.todo_list.render()
  • Trigger other widget clicks: ui.add_button.on_click()
  • Modify state variables: state.counter += 1
  • Use array methods: todos.push({text: "new", done: false})
  • Use control flow: if text != "" { ... }

2. Rust Event Handling -- MatchEvent Trait

The MatchEvent trait is the Rust-side event dispatcher. It receives platform events

…

자주 묻는 질문

‘이벤트’란 무엇인가요?

마우스 클릭, 키 입력, 프로그램 로딩처럼 일어나는 일입니다.

‘Splash’란 무엇인가요?

Makepad에서 사용자 인터페이스의 모습과 기본 동작을 Rust보다 더 간단하게 설명하는 데 쓰는 언어입니다.

왜 `.render()`를 호출해야 하나요?

Makepad에게 화면의 일부를 다시 그리라고 알리는 것과 같습니다. 사용자가 보는 내용을 새 정보나 변경으로 업데이트합니다.

상세 정보

작성자의 원본 설명

Makepad 2.0 guidance for events; use when building or debugging Makepad UI code.

repo: sickn33/agentic-awesome-skills

인기도

GitHub 스타
48k
순위
#5141
라이선스
MIT
업데이트
2026. 10. 15.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬