]> uap-core.de Git - note.git/commitdiff
add UiContext call_action method
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Sun, 17 May 2026 09:07:22 +0000 (11:07 +0200)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Sun, 17 May 2026 09:07:22 +0000 (11:07 +0200)
ui-rs/src/ui/toolkit.rs

index d701ced45a720f55351da9add730b474a718af00..050dd1ba994c73977611347f6b392179166f52de 100644 (file)
@@ -107,6 +107,13 @@ impl UiContext {
         let cstr = CString::new(name).unwrap();
         ui_add_action(self.ptr, cstr.as_ptr(), Some(action_event_wrapper::<T>), ptr as *mut c_void);
     }
+
+    pub fn call_action(&self, action: &str) {
+        let cstr = CString::new(action).unwrap();
+        unsafe {
+            ui_call_action(self.ptr, cstr.as_ptr());
+        }
+    }
 }
 
 pub extern "C" fn destroy_boxed<T>(data: *mut c_void) {
@@ -208,10 +215,7 @@ impl<T> UiObject<T> {
     }
 
     pub fn call_action(&self, action: &str) {
-        let cstr = CString::new(action).unwrap();
-        unsafe {
-            ui_call_action(self.ctx.ptr, cstr.as_ptr());
-        }
+        self.ctx.call_action(action);
     }
 }