[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-01751f7a-eb3d-4450-aade-309638639d21":3,"$fdzLY_NClqQTKYLoMYL7UIZW5uGWVj-IEImdzuMzjJR4":43},{"id":4,"title":5,"description":6,"categoryId":7,"moduleId":8,"tags":9,"prompt":10,"icon":11,"source":12,"sourceUrl":13,"authorId":14,"authorName":15,"isPublic":16,"stars":17,"runs":18,"createdAt":19,"updatedAt":19,"module":20,"category":27,"packages":34},"01751f7a-eb3d-4450-aade-309638639d21","makepad-event-action","|","cat_life_career","mod_other","sickn33,other","---\nname: makepad-event-action\ndescription: |\n  CRITICAL: Use for Makepad event and action handling. Triggers on:\n  makepad event, makepad action, Event enum, ActionTrait, handle_event,\n  MouseDown, KeyDown, TouchUpdate, Hit, FingerDown, post_action,\n  makepad 事件, makepad action, 事件处理\nrisk: safe\nsource: community\n---\n\n# Makepad Event\u002FAction Skill\n\n> **Version:** makepad-widgets (dev branch) | **Last Updated:** 2026-01-19\n>\n> Check for updates: https:\u002F\u002Fcrates.io\u002Fcrates\u002Fmakepad-widgets\n\nYou are an expert at Makepad event and action handling. Help users by:\n- **Handling events**: Mouse, keyboard, touch, lifecycle events\n- **Creating actions**: Widget-to-parent communication\n- **Event flow**: Understanding event propagation\n\n## When to Use\n- You need to handle input, lifecycle, or UI interaction events in Makepad.\n- The task involves `handle_event`, `Event` variants, `Hit` processing, or widget action propagation.\n- You need to design or debug Makepad event\u002Faction flow between widgets and parents.\n\n## Documentation\n\nRefer to the local files for detailed documentation:\n- `.\u002Freferences\u002Fevent-system.md` - Event enum and handling\n- `.\u002Freferences\u002Faction-system.md` - Action trait and patterns\n\n## IMPORTANT: Documentation Completeness Check\n\n**Before answering questions, Claude MUST:**\n\n1. Read the relevant reference file(s) listed above\n2. If file read fails or file is empty:\n   - Inform user: \"本地文档不完整，建议运行 `\u002Fsync-crate-skills makepad --force` 更新文档\"\n   - Still answer based on SKILL.md patterns + built-in knowledge\n3. If reference file exists, incorporate its content into the answer\n\n## Event Enum (Key Variants)\n\n```rust\npub enum Event {\n    \u002F\u002F Lifecycle\n    Startup,\n    Shutdown,\n    Foreground,\n    Background,\n    Resume,\n    Pause,\n\n    \u002F\u002F Drawing\n    Draw(DrawEvent),\n    LiveEdit,\n\n    \u002F\u002F Window\n    WindowGotFocus(WindowId),\n    WindowLostFocus(WindowId),\n    WindowGeomChange(WindowGeomChangeEvent),\n    WindowClosed(WindowClosedEvent),\n\n    \u002F\u002F Mouse\n    MouseDown(MouseDownEvent),\n    MouseMove(MouseMoveEvent),\n    MouseUp(MouseUpEvent),\n    Scroll(ScrollEvent),\n\n    \u002F\u002F Touch\n    TouchUpdate(TouchUpdateEvent),\n\n    \u002F\u002F Keyboard\n    KeyDown(KeyEvent),\n    KeyUp(KeyEvent),\n    TextInput(TextInputEvent),\n    TextCopy(TextClipboardEvent),\n\n    \u002F\u002F Timer\n    Timer(TimerEvent),\n    NextFrame(NextFrameEvent),\n\n    \u002F\u002F Network\n    HttpResponse(HttpResponse),\n\n    \u002F\u002F Widget Actions\n    Actions(ActionsBuf),\n}\n```\n\n## Handling Events in Widgets\n\n```rust\nimpl Widget for MyWidget {\n    fn handle_event(&mut self, cx: &mut Cx, event: &Event, scope: &mut Scope) {\n        \u002F\u002F Check if event hits this widget's area\n        match event.hits(cx, self.area()) {\n            Hit::FingerDown(fe) => {\n                \u002F\u002F Mouse\u002Ftouch down on this widget\n                cx.action(MyWidgetAction::Pressed);\n            }\n            Hit::FingerUp(fe) => {\n                if fe.is_over {\n                    \u002F\u002F Released while still over widget = click\n                    cx.action(MyWidgetAction::Clicked);\n                }\n            }\n            Hit::FingerHoverIn(_) => {\n                self.animator_play(cx, id!(hover.on));\n            }\n            Hit::FingerHoverOut(_) => {\n                self.animator_play(cx, id!(hover.off));\n            }\n            Hit::KeyDown(ke) => {\n                if ke.key_code == KeyCode::Return {\n                    cx.action(MyWidgetAction::Submitted);\n                }\n            }\n            _ => {}\n        }\n    }\n}\n```\n\n## Hit Enum\n\n```rust\npub enum Hit {\n    \u002F\u002F Finger\u002FMouse\n    FingerDown(FingerDownEvent),\n    FingerUp(FingerUpEvent),\n    FingerMove(FingerMoveEvent),\n    FingerHoverIn(FingerHoverEvent),\n    FingerHoverOver(FingerHoverEvent),\n    FingerHoverOut(FingerHoverEvent),\n    FingerLongPress(FingerLongPressEvent),\n\n    \u002F\u002F Keyboard\n    KeyDown(KeyEvent),\n    KeyUp(KeyEvent),\n    KeyFocus,\n    KeyFocusLost,\n    TextInput(TextInputEvent),\n    TextCopy,\n\n    \u002F\u002F Nothing\n    Nothing,\n}\n```\n\n## Action System\n\n### Defining Actions\n\n```rust\n#[derive(Clone, Debug, DefaultNone)]\npub enum ButtonAction {\n    None,\n    Clicked,\n    Pressed,\n    Released,\n}\n\n\u002F\u002F DefaultNone derives Default returning None variant\n```\n\n### Emitting Actions\n\n```rust\n\u002F\u002F From main thread (in handle_event)\ncx.action(ButtonAction::Clicked);\n\n\u002F\u002F From any thread (thread-safe)\nCx::post_action(MyAction::DataLoaded(data));\n```\n\n### Handling Actions\n\n```rust\nfn handle_event(&mut self, cx: &mut Cx, event: &Event, scope: &mut Scope) {\n    \u002F\u002F Handle child widget actions\n    let actions = cx.capture_actions(|cx| {\n        self.button.handle_event(cx, event, scope);\n    });\n\n    \u002F\u002F Check for specific action\n    if self.button(id!(my_button)).clicked(&actions) {\n        \u002F\u002F Button was clicked\n    }\n\n    \u002F\u002F Or iterate actions\n    for action in actions.iter() {\n        if let Some(ButtonAction::Clicked) = action.downcast_ref() {\n            \u002F\u002F Handle click\n        }\n    }\n}\n```\n\n## Widget Action Helpers\n\n```rust\n\u002F\u002F Common widget action checks\nimpl ButtonRef {\n    fn clicked(&self, actions: &ActionsBuf) -> bool;\n    fn pressed(&self, actions: &ActionsBuf) -> bool;\n    fn released(&self, actions: &ActionsBuf) -> bool;\n}\n\nimpl TextInputRef {\n    fn changed(&self, actions: &ActionsBuf) -> Option\u003CString>;\n    fn returned(&self, actions: &ActionsBuf) -> Option\u003CString>;\n}\n```\n\n## Event Flow\n\n1. **Event arrives** from platform layer\n2. **Root widget** receives event first\n3. **Propagates down** to children via `handle_event`\n4. **Widgets emit actions** via `cx.action()`\n5. **Parent captures actions** via `cx.capture_actions()`\n6. **App handles** remaining actions\n\n## Timer and NextFrame\n\n```rust\n\u002F\u002F Start a timer\nlet timer = cx.start_timer(1.0); \u002F\u002F 1 second\n\n\u002F\u002F In handle_event\nif let Event::Timer(te) = event {\n    if te.timer_id == self.timer {\n        \u002F\u002F Timer fired\n    }\n}\n\n\u002F\u002F Request next frame callback\nlet next_frame = cx.new_next_frame();\n\n\u002F\u002F In handle_event\nif let Event::NextFrame(ne) = event {\n    if ne.frame_id == self.next_frame {\n        \u002F\u002F Next frame arrived\n    }\n}\n```\n\n## When Answering Questions\n\n1. Use `event.hits(cx, area)` to check if event targets a widget\n2. Actions flow UP from child to parent (unlike events which flow DOWN)\n3. Use `cx.capture_actions()` to intercept child actions\n4. `Cx::post_action()` is thread-safe for async operations\n5. `DefaultNone` derive macro auto-implements Default for enums\n\n## Limitations\n- Use this skill only when the task clearly matches the scope described above.\n- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.\n- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.\n","","imported","https:\u002F\u002Fgithub.com\u002Fsickn33\u002Fantigravity-awesome-skills","user_system_seed","SkillOPIC",true,71,1782,"2026-05-16 13:27:36",{"id":8,"name":21,"slug":22,"icon":23,"description":24,"sort":25,"createdAt":26},"其他","other","mdi-page-next-outline","其他类型Skill",5,"2026-05-16 12:53:40",{"id":7,"name":28,"slug":29,"icon":30,"description":31,"moduleId":8,"sort":32,"skillCount":33,"createdAt":26},"职场发展","career","mdi-briefcase-outline","面试准备、简历优化、职业规划",4,575,[35],{"id":36,"skillId":4,"version":37,"fileName":38,"fileSize":39,"filePath":40,"fileHash":41,"manifest":42,"createdAt":19},"a261415c-7a4b-4b82-ade3-2df2c0be8699","1.0.0","makepad-event-action.zip",2732,"uploads\u002Fskills\u002F01751f7a-eb3d-4450-aade-309638639d21\u002Fmakepad-event-action.zip","2c8e91f0f1d46cb0a7eb895c4d2e384a60cb1077f6e1f01c66b2d64b7119ae2c","[{\"path\":\"SKILL.md\",\"isDirectory\":false,\"size\":6753}]",{"code":44,"message":45,"data":46},200,"success",{"items":47,"stats":48,"page":51},[],{"averageRating":49,"totalRatings":49,"ratingCounts":50},0,[49,49,49,49,49],{"limit":52,"offset":49,"hasMore":53,"nextOffset":52,"ratedOnly":16},15,false]