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

[vendor/darwin]: Fix missing cmd: SEL parameter in some delegate callbacks, and add a few more method bindings for NSView and NSWindow #3074

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sackboy19
Copy link

This PR fixes a bug in NSWindow.odin and NSApplication.odin where the "cmd" parameter is not getting passed to the delegate callback functions, which results in a signature mismatch bug and causes a crash when trying to use an argument from a delegate callback in an NSApplicationDelegate or NSWindowDelegate

Example reproduction of the bug: (using SDL)

// create a window delegate
window_delegate: NS.WindowDelegateTemplate

// set the resize callback
window_delegate.windowDidResize = proc(notification: ^NS.Notification) {
	// attempt to print the parameter 'notification's description
	name := notification->name() /* crashes because notification is not 
					a pointer to a Notifiction, but rather a SEL object */

	// however with my commit this is fixed and the following works:
	fmt.println(name->odinString()) // prints "NSWindowDidResizeNotification"
}

// get the native window from SDL
window_system_info: SDL.SysWMinfo
SDL.GetWindowWMInfo(window, &window_system_info)
native_window := (^NS.Window)(window_system_info.info.cocoa.window)

// set the window delegate
native_window->setDelegate(NS.window_delegate_register_and_alloc(window_delegate, "myDelegate", context))

This PR also adds a few more method bindings for NSView and NSWindow

…n and NSWindow. Also added a few more method bindings for NSView and NSWindow
@github-actions github-actions bot added the stale label Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant