@@ -8,19 +8,28 @@ const html = @embedFile("index.html");
88pub fn main () ! void {
99 var nwin = webui .newWindow ();
1010
11- _ = nwin .bind ("my_function_string" , my_function_string );
12- _ = nwin .bind ("my_function_integer" , my_function_integer );
13- _ = nwin .bind ("my_function_boolean" , my_function_boolean );
14- _ = nwin .bind ("my_function_with_response" , my_function_with_response );
15- _ = nwin .bind ("my_function_raw_binary" , my_function_raw_binary );
11+ _ = try nwin .binding ("my_function_string" , getString );
12+ // _ = try nwin.bind("my_function_string", my_function_string);
13+ _ = try nwin .binding ("my_function_integer" , getInteger );
14+ // _ = try nwin.bind("my_function_integer", my_function_integer);
15+ _ = try nwin .bind ("my_function_boolean" , my_function_boolean );
16+ _ = try nwin .bind ("my_function_with_response" , my_function_with_response );
17+ _ = try nwin .bind ("my_function_raw_binary" , my_function_raw_binary );
1618
17- _ = nwin .show (html );
19+ try nwin .show (html );
1820
1921 webui .wait ();
2022
2123 webui .clean ();
2224}
2325
26+ fn getString (str1 : [:0 ]const u8 , str2 : [:0 ]const u8 ) void {
27+ // Hello
28+ std .debug .print ("my_function_string 1: {s}\n " , .{str1 });
29+ // World
30+ std .debug .print ("my_function_string 2: {s}\n " , .{str2 });
31+ }
32+
2433fn my_function_string (e : * webui.Event ) void {
2534 // JavaScript:
2635 // my_function_string('Hello', 'World`);
@@ -35,6 +44,12 @@ fn my_function_string(e: *webui.Event) void {
3544 std .debug .print ("my_function_string 2: {s}\n " , .{str_2 });
3645}
3746
47+ fn getInteger (n1 : i64 , n2 : i64 , n3 : i64 , f1 : f64 ) void {
48+ std .debug .print ("number is {},{},{},{}" , .{
49+ n1 , n2 , n3 , f1 ,
50+ });
51+ }
52+
3853fn my_function_integer (e : * webui.Event ) void {
3954 // JavaScript:
4055 // my_function_integer(123, 456, 789, 12345.6789);
@@ -95,11 +110,11 @@ fn my_function_raw_binary(e: *webui.Event) void {
95110
96111 // Or e.getStringAt(0);
97112 const raw_1 = e .getString ();
98- const raw_2 = e .getStringAt (1 );
113+ const raw_2 = e .getRawAt (1 );
99114
100115 // Or e.getSizeAt(0);
101- const len_1 = e .getSize ();
102- const len_2 = e .getSizeAt (1 );
116+ const len_1 = e .getSize () catch return ;
117+ const len_2 = e .getSizeAt (1 ) catch return ;
103118
104119 // Print raw_1
105120 std .debug .print ("my_function_raw_binary 1 ({} bytes): " , .{len_1 });
0 commit comments