ui/common/context.c

changeset 1197
4bbf0487509f
parent 1195
6ec3c71ba298
child 1198
5bb4366b0c32
--- a/ui/common/context.c	Sat Jun 13 17:19:59 2026 +0200
+++ b/ui/common/context.c	Sun Jun 14 10:52:28 2026 +0200
@@ -943,3 +943,21 @@
     UiVar *var = uic_get_var_t(ctx, name, UI_VAR_GENERIC);
     return var ? var->value : NULL;
 }
+
+
+static void attachment_action_callback(UiEvent *event, void *action) {
+    if(event->document) {
+        UiContext *ctx = ui_document_context(event->document);
+        ui_call_action_on(ctx, action);
+    }
+}
+
+void ui_context_onattach_action(UiContext *ctx, const char *action) {
+    ctx->onattach = attachment_action_callback;
+    ctx->onattachdata = ui_strdup(ctx, action);
+}
+
+void ui_context_ondetach_action(UiContext *ctx, const char *action) {
+    ctx->ondetach = attachment_action_callback;
+    ctx->ondetachdata = ui_strdup(ctx, action);
+}

mercurial