]> uap-core.de Git - note.git/commitdiff
extend Event struct
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Mon, 13 Apr 2026 17:56:20 +0000 (19:56 +0200)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Mon, 13 Apr 2026 17:56:20 +0000 (19:56 +0200)
application/src/main.rs
ui-rs/src/ui/event.rs

index daf250ee55252e4b42bea7dd2c6635ea85d538c9..3ed693dfc05cd1a87c6eeeae3bb5958fbc9372ee 100644 (file)
@@ -13,17 +13,21 @@ struct TestData {
     i: i32
 }
 
-impl ui::Application for App {
-    fn on_startup(&self) {
-        let testdata = TestData { i: 0 } ;
+fn create_window() {
+    let testdata = TestData { i: 0 } ;
+
+    let window = ui::window("note", testdata, |obj, _data| {
+        obj.button_builder().label("Hello").onclick(|e| {
+            println!("Button clicked: {}", e.data.i);
+            e.data.i += 1;
+        }).create();
+    });
 
-        let window = ui::window("note", testdata, |obj, _data| {
-            obj.button_builder().label("Hello").onclick(|e| {
-                println!("Button clicked: {}", e.data.i);
-                e.data.i += 1;
-            }).create();
-        });
+    window.show();
+}
 
-        window.show();
+impl ui::Application for App {
+    fn on_startup(&self) {
+        create_window();
     }
 }
index d8e0392511c4502a861496dde4001ba85eacee0d..bbf822c4645bc020f4894fd89eaef2aab2c52dcf 100644 (file)
@@ -1,9 +1,30 @@
+#![allow(dead_code)]
+
 use std::ffi::c_void;
-use crate::ui::ffi;
-use crate::ui::ffi::UiEvent;
+use crate::ui::{ffi, UiDouble, UiInteger, UiString, UiText};
+use crate::ui::ffi::{UiEvent, UiRange};
 
 pub struct Event<'a, T> {
-    pub data: &'a mut T
+    pub data: &'a mut T,
+    pub event_type: EventType<'a>,
+    pub intval: i32,
+    pub set: bool
+}
+
+pub enum EventType<'a> {
+    Null,
+    Pointer,
+    String(String),
+    IntegerValue(&'a mut UiInteger),
+    StringValue(&'a mut UiString),
+    TextValue(&'a mut UiText),
+    DoubleValue(&'a mut UiDouble),
+    RangeValue(&'a mut UiRange),
+    ListSelection,
+    ListElement,
+    Dnd,
+    SubList,
+    FileList
 }
 
 pub struct EventWrapper<T> {
@@ -17,7 +38,16 @@ pub extern "C" fn event_wrapper<T>(e: *const ffi::UiEvent, data: *mut c_void) {
         let wdata_ptr = ui_event_get_windowdata(e);
         let wdata = &mut *(wdata_ptr as *mut T);
 
-        let mut event = Event { data: wdata };
+        //let ev_type = ui_event_get_eventdatatype(e);
+        let ev_int = ui_event_get_int(e);
+        let ev_set = ui_event_get_set(e) != 0;
+
+        let mut event = Event {
+            data: wdata,
+            event_type: EventType::Null,
+            intval: ev_int,
+            set: ev_set
+        };
 
         (wrapper.callback)(&mut event);
     }
@@ -26,4 +56,9 @@ pub extern "C" fn event_wrapper<T>(e: *const ffi::UiEvent, data: *mut c_void) {
 
 extern "C" {
     fn ui_event_get_windowdata(event: *const UiEvent) -> *const c_void;
+    fn ui_event_get_document(event: *const UiEvent) -> *const c_void;
+    fn ui_event_get_eventdata(event: *const UiEvent) -> *const c_void;
+    fn ui_event_get_eventdatatype(event: *const UiEvent) -> i32;
+    fn ui_event_get_int(event: *const UiEvent) -> i32;
+    fn ui_event_get_set(event: *const UiEvent) -> i32;
 }
\ No newline at end of file