implement tabview value binding (Cocoa)

Sun, 19 Oct 2025 10:10:06 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 19 Oct 2025 10:10:06 +0200
changeset 863
589bca248476
parent 862
670b2c03413f
child 864
d39301e8f962

implement tabview value binding (Cocoa)

ui/cocoa/TabView.h file | annotate | diff | comparison | revisions
ui/cocoa/TabView.m file | annotate | diff | comparison | revisions
--- a/ui/cocoa/TabView.h	Sat Oct 18 12:23:52 2025 +0200
+++ b/ui/cocoa/TabView.h	Sun Oct 19 10:10:06 2025 +0200
@@ -51,5 +51,7 @@
 
 - (id)init:(UiObject*)obj args:(UiTabViewArgs*)args;
 
+@end
 
-@end
+int64_t ui_nstabview_get(UiInteger *i);
+void ui_nstabview_set(UiInteger *i, int64_t value);
--- a/ui/cocoa/TabView.m	Sat Oct 18 12:23:52 2025 +0200
+++ b/ui/cocoa/TabView.m	Sun Oct 19 10:10:06 2025 +0200
@@ -50,6 +50,13 @@
         self.tabViewType = NSNoTabsNoBorder;
     }
     
+    if(_var) {
+        UiInteger *i = _var->value;
+        i->obj = (__bridge void*)self;
+        i->get = ui_nstabview_get;
+        i->set = ui_nstabview_set;
+    }
+    
     return self;
 }
 
@@ -113,3 +120,15 @@
 }
 
 @end
+
+int64_t ui_nstabview_get(UiInteger *i) {
+    UiTopTabView *tabview = (__bridge UiTopTabView*)i->obj;
+    i->value = [tabview indexOfTabViewItem:tabview.selectedTabViewItem];
+    return i->value;
+}
+
+void ui_nstabview_set(UiInteger *i, int64_t value) {
+    UiTopTabView *tabview = (__bridge UiTopTabView*)i->obj;
+    [tabview selectTab:(int)value];
+    i->value = [tabview indexOfTabViewItem:tabview.selectedTabViewItem];
+}

mercurial