makepad-2.0-app-structure

Scaffolds Makepad 2.0 applications with Rust and Splash script integration patterns.

747|87|Updated Jan 10, 2026
One-click install
npx skills add https://github.com/ZhangHanDong/makepad-skills --skill makepad-2-0-app-structure
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: makepad-2.0-app-structure
Source: https://github.com/ZhangHanDong/makepad-skills/tree/main/skills/makepad-2.0-app-structure
Command: npx skills add https://github.com/ZhangHanDong/makepad-skills --skill makepad-2-0-app-structure

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Setting up a Makepad 2.0 application requires correctly wiring Rust lifecycle code with Splash UI scripts, and mistakes in registration order, event dispatch, or Rust-Splash communication cause confusing failures. This Skill provides working templates and integration patterns so the app structure is correct from the start.

Core Features & Use Cases

  • Complete App Boilerplate: Provides a minimal working template including Cargo.toml, app_main!, script_mod!, App::run, MatchEvent, and AppMain implementations.
  • Rust-Splash Bridge Patterns: Documents script_eval!, script_apply_eval!, inline on_click/on_render handlers, and widget access via ids! for two-way communication.
  • Platform Integration Guidance: Covers hot reload flags, Makepad Studio debugging, native audio I/O via cx.audio_output/cx.audio_input, and macOS specifics like NSStatusBar and CGEvent taps.
  • Use Case: When starting a new Makepad project, load this Skill to generate a compilable counter-style app skeleton, then extend it with state management via mod.state and action handling in MatchEvent.

Quick Start

Ask the AI to create a minimal Makepad 2.0 app with a window, a label, and a button that increments a counter using the app-structure skill.

Frequently Asked Questions about makepad-2.0-app-structure

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a new Makepad 2.0 app in Rust?

Define a struct deriving Script and ScriptHook with a #[live] ui: WidgetRef field, call app_main!(App), define UI in script_mod!, and implement App::run to register widget modules before calling App::from_script_mod. Implement MatchEvent for actions and AppMain for event dispatch.

How does Rust communicate with Splash scripts in Makepad?

Rust calls Splash via script_eval! to update mod.state and trigger renders, or script_apply_eval! to patch widget properties. Splash calls back through inline handlers like on_click and on_render, while Rust reads widget actions in MatchEvent::handle_actions using ids! selectors.

How do I enable hot reload in a Makepad app?

Run the app with cargo run -p my-app -- --hot. The --hot flag watches script_mod! source files and refreshes the UI on save without recompilation, but it only applies to Splash DSL changes; Rust code changes still require a rebuild.

Can I use audio input and output in Makepad Splash scripts?

No, audio is not exposed to Splash scripting. All audio processing must happen in Rust using cx.audio_output and cx.audio_input callbacks, which run on a real-time thread. Use Arc<AtomicU64> to pass audio data safely to the UI thread.

Why is my Makepad MatchEvent handle_actions never called?

handle_actions only fires if you call self.match_event(cx, event) inside your AppMain::handle_event implementation before forwarding the event to the widget tree. Omitting that call silently disables all MatchEvent trait methods.

How do I add a macOS menu bar icon to a Makepad app?

Use the makepad_objc_sys crate to call NSStatusBar via msg_send, since Makepad has no built-in status bar API. Avoid the objc2 crate because it creates a conflicting NSApplication instance, and use LSUIElement in Info.plist instead of show_in_dock(false).