[Openmcl-devel] Weird problem with sheet return code

Ron Garret ron at flownet.com
Tue Feb 9 23:45:55 PST 2010


Figured it out.  Had the wrong signature for alertDidEnd:returnCode:contextInfo:.  Correct version is:

(objc:defmethod #/alertDidEnd:returnCode:contextInfo:
                ((self gui::hemlock-frame) alert (return-code integer) context-info)

...

rg

On Feb 9, 2010, at 6:28 PM, Ron Garret wrote:

> I'm trying to display a window sheet using something like the following code:
> 
> 
> (setf alert (make-instance 'ns:ns-alert))
> (#/setMessageText: alert #@"Foo!")
> (#/addButtonWithTitle: alert #@"Baz")
> (#/addButtonWithTitle: alert #@"Bar")
> 
> (#/addItem: GUI::*TEXT-VIEW-CONTEXT-MENU* (#/separatorItem ns:ns-menu-item))
> (#/addItemWithTitle:action:keyEquivalent:
> GUI::*TEXT-VIEW-CONTEXT-MENU* #@"Foo" (objc:@selector #/foo:) #@"")
> 
> (objc:defmethod #/alertDidEnd:returnCode:contextInfo:
>                ((self gui::hemlock-frame) return-code context-info)
>  (print return-code (HEMLOCK-EXT:TOP-LISTENER-OUTPUT-STREAM))
>  (%null-ptr))
> 
> (objc:defmethod (#/foo: :void) ((self gui::hemlock-text-view) sender)
>  (declare (ignore sender))
>  (let ((w (slot-value (slot-value self 'gui::pane) 'ns:_window)))
>    (#/beginSheetModalForWindow:modalDelegate:didEndSelector:contextInfo:
>     alert w w (objc:@selector #/alertDidEnd:returnCode:contextInfo:) (%null-ptr))))
> 
> 
> This works, except for one thing: the value passed as the returnCode argument to alertDidEnd:returnCode:contextInfo: is the alert object, not as the Cocoa docs say, an integer indicating which button the user pressed.  What am I doing wrong?
> 
> Thanks,
> rg
> 
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel




More information about the Openmcl-devel mailing list