makepad-event-action_skill

This skill helps you handle Makepad events and actions, enabling widget-to-parent communication and robust event flow.
  • Shell

715

GitHub Stars

1

Bundled Files

2 months ago

Catalog Refreshed

4 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill zhanghandong/makepad-skills --skill makepad-event-action

  • SKILL.md6.0 KB

Overview

This skill provides focused guidance for Makepad event and action handling in widgets and apps. It explains how to detect hits, respond to mouse/keyboard/touch events, create and emit actions, and capture child widget actions so parents can react. Use it to implement robust input, lifecycle, timer, and inter-widget communication patterns in Makepad-based Rust UI code.

How this skill works

The skill inspects the Event enum and Hit enum to determine how input and lifecycle events should be matched to widget areas using event.hits(cx, area). It shows how widgets emit actions with cx.action(...) and how parents capture those actions with cx.capture_actions(...) or by iterating an ActionsBuf. It also covers timers, next-frame callbacks, and thread-safe posting via Cx::post_action().

When to use it

  • Implementing widget input handling (mouse, touch, keyboard)
  • Coordinating child-to-parent communication via actions
  • Managing lifecycle events (startup, pause, resume)
  • Scheduling timers and frame callbacks
  • Handling async results or background threads that must notify the UI

Best practices

  • Use event.hits(cx, area) to limit work to relevant widgets and avoid false positives
  • Keep actions small, typed enums (derive DefaultNone for a None variant) to simplify pattern matching
  • Capture child actions with cx.capture_actions() and check with helper methods (e.g., button.clicked(&actions))
  • Use Cx::post_action() for thread-safe notifications from background threads
  • Prefer explicit matching of Event variants (Timer, NextFrame) using stored ids to avoid cross-talk

Example use cases

  • A clickable button: detect FingerDown/FingerUp hits and emit ButtonAction::Clicked via cx.action
  • Text input: capture TextInput/TextCopy events and use TextInputRef helpers to extract changes
  • Parent container: call cx.capture_actions() around child handle_event calls and react to ButtonAction::Clicked to update state
  • Timers: start a timer with cx.start_timer(duration) and match Event::Timer(timer_event) to perform periodic updates
  • Async load: spawn a background task and call Cx::post_action(MyAction::DataLoaded(data)) to deliver results to the main thread

FAQ

Events flow down from the root to children; actions flow up from child to parent. Use cx.capture_actions() in the parent to intercept child actions.

When should I use Cx::post_action() vs cx.action()?

Use cx.action() inside the UI thread during handle_event. Use Cx::post_action() from background threads or async tasks because it is thread-safe.

How do I detect a click vs a press?

Match Hit::FingerDown to emit Pressed and match Hit::FingerUp with fe.is_over true to emit Clicked (released while still over widget).

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational
makepad-event-action skill by zhanghandong/makepad-skills | VeilStrat