Skip to content

Commit

Permalink
gg: fn (data voidptr, e &Event) for events, allows methods
Browse files Browse the repository at this point in the history
  • Loading branch information
medvednikov committed Nov 24, 2023
1 parent fc69b2f commit 399af67
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions tutorials/building_a_simple_web_blog_with_vweb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,8 @@ Run
v -d use_openssl -o blog -prod . && strip ./blog
```

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
binary size will increase to ~700KB.
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 binary size will increase to ~700KB.


### To be continued...
Expand Down
7 changes: 5 additions & 2 deletions vlib/gg/gg.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ pub:
cleanup_fn FNCb = unsafe { nil }
fail_fn FNFail = unsafe { nil }
//
event_fn FNEvent = unsafe { nil }
quit_fn FNEvent = unsafe { nil }
event_fn FNEvent = unsafe { nil }
on_event FNEvent2 = unsafe { nil }
quit_fn FNEvent = unsafe { nil }
//
keydown_fn FNKeyDown = unsafe { nil }
keyup_fn FNKeyUp = unsafe { nil }
Expand Down Expand Up @@ -353,6 +354,8 @@ fn gg_event_fn(ce voidptr, user_data voidptr) {
}
if ctx.config.event_fn != unsafe { nil } {
ctx.config.event_fn(e, ctx.config.user_data)
} else if ctx.config.on_event != unsafe { nil } {
ctx.config.on_event(ctx.config.user_data, e)
}
match e.typ {
.mouse_move {
Expand Down
2 changes: 2 additions & 0 deletions vlib/gg/gg.v
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ pub type FNCb = fn (data voidptr)

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

pub type FNEvent2 = fn (data voidptr, e &Event)

pub type FNFail = fn (msg string, data voidptr)

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

0 comments on commit 399af67

Please sign in to comment.