Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add helper methods for callback functions #9

Closed
jebej opened this issue Sep 14, 2020 · 3 comments · Fixed by #11
Closed

Add helper methods for callback functions #9

jebej opened this issue Sep 14, 2020 · 3 comments · Fixed by #11

Comments

@jebej
Copy link
Contributor

jebej commented Sep 14, 2020

Would you be interested in having helper methods to set the callback functions which automatically create the function pointer with @cfunction ? Since the signature is fixed by the library we can just assume that the user is passing a valid method.

Eg. we could define:

function mfb_set_keyboard_callback(window, keyboard::Function)
    keyboard_c = @cfunction(keyboard, Cvoid, (Ptr{Cvoid}, mfb_key, mfb_key_mod, Bool))
    mfb_set_keyboard_callback(window, keyboard_c)
end

Let me know if that would be good to have, and if the naming, or something else would need to be changed

@aviks
Copy link
Owner

aviks commented Sep 14, 2020

Yeah, that might be a good idea!

@jebej
Copy link
Contributor Author

jebej commented Sep 14, 2020

Any input on the api? Should I just add methods to the various mfb_set_*_callback functions?

@jebej
Copy link
Contributor Author

jebej commented Sep 14, 2020

I had to add $ to the macro call since the function pointer must be created at runtime. I am not sure whether that's a drawback or not.

@aviks aviks closed this as completed in #11 Sep 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants