-
Notifications
You must be signed in to change notification settings - Fork 128
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
minigui docs: event handler must be a delegate #475
Comments
yeah if you use local variables it is automatically a delegate so in most cases it will work but an empty function (or just a writeln logger) won't. useCapture means the event is triggered on the capture phase instead of the bubble phase. the docs talk about this but it is mostly a javascript thnig you can look up too maybe ill rewrite that soon |
That was exactly my case. I just slapped a writeln to check if it works. Then why minigui insists on a delegate? If a programmer is ok with a plain function that doesn't capture context, minigui should also be ok |
It just requires adding like 12 function overloads for the function to delegate adapters.... easier to just put the word at the call site lol |
OpenD could probably implicitly convert function to delegate, codegen wise you can do it and there's no loss of information (you can do it in library too, put a thunk in the funcptr then ptr is the actual funcptr). So solid maybe putting that right in the compiler but might also cause side effects. |
https://dpldocs.info/experimental-docs/arsd.minigui.Event.html
Trying to actually compile an example from this page
throws
arsd/minigui.d(1416): Error: static assert: "Your handler wasn't usable because it wasn't passed a delegate. Use the delegate keyword at the call site."
Marking lambda as a delegate solves the issue:
no biggie but it's worth mentioning in the docs.
Also,
useCapture
isn't documented anywhereThe text was updated successfully, but these errors were encountered: