Skip to content

Commit 399af67

Browse files
committed
gg: fn (data voidptr, e &Event) for events, allows methods
1 parent fc69b2f commit 399af67

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

tutorials/building_a_simple_web_blog_with_vweb/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,8 +417,8 @@ Run
417417
v -d use_openssl -o blog -prod . && strip ./blog
418418
```
419419

420-
This will result in a ~400KB binary. `-d use_openssl` tells vweb to link to OpenSSL. Without this flag mbedtls will be embedded, and the
421-
binary size will increase to ~700KB.
420+
This will result in a ~400KB binary. `-d use_openssl` tells vweb to link to OpenSSL.
421+
Without this flag mbedtls will be embedded, and the binary size will increase to ~700KB.
422422

423423

424424
### To be continued...

vlib/gg/gg.c.v

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@ pub:
7070
cleanup_fn FNCb = unsafe { nil }
7171
fail_fn FNFail = unsafe { nil }
7272
//
73-
event_fn FNEvent = unsafe { nil }
74-
quit_fn FNEvent = unsafe { nil }
73+
event_fn FNEvent = unsafe { nil }
74+
on_event FNEvent2 = unsafe { nil }
75+
quit_fn FNEvent = unsafe { nil }
7576
//
7677
keydown_fn FNKeyDown = unsafe { nil }
7778
keyup_fn FNKeyUp = unsafe { nil }
@@ -353,6 +354,8 @@ fn gg_event_fn(ce voidptr, user_data voidptr) {
353354
}
354355
if ctx.config.event_fn != unsafe { nil } {
355356
ctx.config.event_fn(e, ctx.config.user_data)
357+
} else if ctx.config.on_event != unsafe { nil } {
358+
ctx.config.on_event(ctx.config.user_data, e)
356359
}
357360
match e.typ {
358361
.mouse_move {

vlib/gg/gg.v

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ pub type FNCb = fn (data voidptr)
99

1010
pub type FNEvent = fn (e &Event, data voidptr)
1111

12+
pub type FNEvent2 = fn (data voidptr, e &Event)
13+
1214
pub type FNFail = fn (msg string, data voidptr)
1315

1416
pub type FNKeyDown = fn (c KeyCode, m Modifier, data voidptr)

0 commit comments

Comments
 (0)