mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
gg: update the mouse click callback to pass what mouse button was clicked too (#10225)
This commit is contained in:
parent
6e493ca8ca
commit
9fab4af3f1
@ -125,3 +125,10 @@ pub enum KeyCode {
|
||||
right_super = 347
|
||||
menu = 348
|
||||
}
|
||||
|
||||
pub enum MouseButton {
|
||||
left = 0
|
||||
right = 1
|
||||
middle = 2
|
||||
invalid = 256
|
||||
}
|
||||
|
@ -22,6 +22,8 @@ pub type FNKeyDown = fn (c KeyCode, m Modifier, x voidptr)
|
||||
|
||||
pub type FNMove = fn (x f32, y f32, z voidptr)
|
||||
|
||||
pub type FNClick = fn (x f32, y f32, button MouseButton, z voidptr)
|
||||
|
||||
pub type FNChar = fn (c u32, x voidptr)
|
||||
|
||||
pub struct Event {
|
||||
@ -32,7 +34,7 @@ pub mut:
|
||||
char_code u32
|
||||
key_repeat bool
|
||||
modifiers u32
|
||||
mouse_button sapp.MouseButton
|
||||
mouse_button MouseButton
|
||||
mouse_x f32
|
||||
mouse_y f32
|
||||
mouse_dx f32
|
||||
@ -81,7 +83,7 @@ pub:
|
||||
// special case of event_fn
|
||||
move_fn FNMove = voidptr(0)
|
||||
// special case of event_fn
|
||||
click_fn FNMove = voidptr(0)
|
||||
click_fn FNClick = voidptr(0)
|
||||
// special case of event_fn
|
||||
// wait_events bool // set this to true for UIs, to save power
|
||||
fullscreen bool
|
||||
@ -295,7 +297,7 @@ fn gg_event_fn(ce &C.sapp_event, user_data voidptr) {
|
||||
.mouse_down {
|
||||
if g.config.click_fn != voidptr(0) {
|
||||
cfn := g.config.click_fn
|
||||
cfn(e.mouse_x / g.scale, e.mouse_y / g.scale, g.config.user_data)
|
||||
cfn(e.mouse_x / g.scale, e.mouse_y / g.scale, e.mouse_button, g.config.user_data)
|
||||
}
|
||||
}
|
||||
else {}
|
||||
|
Loading…
Reference in New Issue
Block a user