[SOLVED] NSAlert as a sheet: How to handle the result?
Posted: Tue Mar 18, 2014 11:01 pm
Hello guys! I would like to implement a NSAlert and showing it as a sheet but I'm stuck at this point. Take a look at this example:
The sheet opens and closes but I don't know how to handle the result to know which button has been pressed. Any clue?
Thanks!
Code: Select all
OpenWindow(0, 0, 0, 480, 320, "AlertSheet Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ButtonGadget(0, 10, 10, 180, 25, "Test sheet!")
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
Alert = CocoaMessage(0, CocoaMessage(0, 0, "NSAlert new"), "autorelease")
CocoaMessage(0, Alert, "addButtonWithTitle:$", @"OK")
CocoaMessage(0, Alert, "addButtonWithTitle:$", @"Cancel")
CocoaMessage(0, Alert, "setMessageText:$", @"This is a message")
CocoaMessage(0, Alert, "setInformativeText:$", @"This is an informative text")
CocoaMessage(0,
Alert,
"beginSheetModalForWindow:", WindowID(0),
"modalDelegate:", 0, ; <====== What to put here instead of 0?
"didEndSelector:", 0, ; <====== here?
"contextInfo:", 0); <========== and here?
EndSelect
ForEver
Thanks!