Discussion:
Display an Alert Sheet at a Specified Screen Position
(too old to reply)
Dave
2015-03-25 22:06:57 UTC
Permalink
Hi All,

I’d like to be able to display and Model Alert Sheet at an arbitrary screen location, is this possible?

If not, if I created a borderless window with a transparent content area and positioned it where I wanted it, could I then display the Sheet using this window using [alert beginSheetModalForWindow:[searchField window] modalDelegate:self didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) contextInfo:nil]; ?

I’d like to be able to display and Model Alert Sheet at an arbitrary screen location, is this possible?

Thanks in advance.
All the Best




_______________________________________________

Cocoa-dev mailing list (Cocoa-***@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/gegs%40ml-in.narkive.net

This email sent to ***@ml-in.narkive.
edward taffel
2015-03-25 22:13:41 UTC
Permalink
use a borderless window, init w/ zero height, and animate the show for requisite frame height.
Post by Dave
Hi All,
I’d like to be able to display and Model Alert Sheet at an arbitrary screen location, is this possible?
I’d like to be able to display and Model Alert Sheet at an arbitrary screen location, is this possible?
Thanks in advance.
All the Best
_______________________________________________
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
https://lists.apple.com/mailman/options/cocoa-dev/etaffel%40me.com
_______________________________________________

Cocoa-dev mailing list (Cocoa-***@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/gegs%40ml-in.narkive.net

This email
Graham Cox
2015-03-25 22:21:12 UTC
Permalink
Post by Dave
I’d like to be able to display and Model Alert Sheet at an arbitrary screen location, is this possible?
It's not possible because by definition a sheet is attached to another window.

You can position a non-sheet modal alert anywhere through its -window property.

--Graham



_______________________________________________

Cocoa-dev mailing list (Cocoa-***@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/gegs%40ml-in.narkive.net

This email sent to ***@ml-in.nark
Mike Abdullah
2015-03-25 23:10:03 UTC
Permalink
Post by Dave
Hi All,
I’d like to be able to display and Model Alert Sheet at an arbitrary screen location, is this possible?
I’d like to be able to display and Model Alert Sheet at an arbitrary screen location, is this possible?
Thanks in advance.
All the Best
_______________________________________________
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
https://lists.apple.com/mailman/options/cocoa-dev/mabdullah%40karelia.com
_______________________________________________

Cocoa-dev mailing list (Cocoa-***@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/gegs%40ml-in.n
Dave
2015-03-26 11:57:56 UTC
Permalink
i tried this just to get something working for now, but it doesn’t seem to affect where the Alert is displayed.

myAlert = [NSAlert alertWithMessageText:@"Do you really want to do that?" defaultButton:@“No" alternateButton:@“Yes" otherButton:nil informativeTextWithFormat:@"It might cause mayhem!”];

myAlertWindow = myAlert.window;
myAlertWindowFrameRect = myAlertWindow.frame;
myAlertWindowFrameRect.origin = myNewOrigin;
[myAlertWindow setFrame:myAlertWindowFrameRect display:YES];

myAlertResponse = [myAlert runModal];
if (myAlertResponse == kDialogResponseYes)
{
}
else
{
}

I’ll investigate doing it using a sheet next week, but it would be nice to have the Alert working in the meantime.

Thanks
Dave


_______________________________________________

Cocoa-dev mailing list (Cocoa-***@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/gegs%40ml-in.narkive.net

This e
Graham Cox
2015-03-26 23:00:02 UTC
Permalink
Post by Dave
i tried this just to get something working for now, but it doesn’t seem to affect where the Alert is displayed.
myAlertWindow = myAlert.window;
myAlertWindowFrameRect = myAlertWindow.frame;
myAlertWindowFrameRect.origin = myNewOrigin;
[myAlertWindow setFrame:myAlertWindowFrameRect display:YES];
myAlertResponse = [myAlert runModal];
if (myAlertResponse == kDialogResponseYes)
{
}
else
{
}
At the point you're setting the frame, the window isn't visible. -runModal shows the window if necessary and positions it on screen, overriding the frame you set. If you force it to be visible before -runModal is called, the frame position you set is not changed. This works:


NSAlert* alert = [NSAlert alertWithMessageText:@"hello" defaultButton:@"ok" alternateButton:@"cancel" otherButton:nil informativeTextWithFormat:@"bing bang wallah wallah bang"];

[alert.window setFrameOrigin:NSMakePoint( 10, 100)];
[alert.window makeKeyAndOrderFront:nil];

NSInteger result = [alert runModal];
Post by Dave
I’ll investigate doing it using a sheet next week, but it would be nice to have the Alert working in the meantime.
Your requirement isn't clear - do you want a sheet to appear as if unattached to a host window, just floating in space? Even if you can achieve it, users will simply assume your app is buggy. Ideas like this are never seen in the wild for good reason.

--Graham



_______________________________________________

Cocoa-dev mailing list (Cocoa-***@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/gegs%40ml-in.narkive.net

This email sent to ***@ml-in.na
Quincey Morris
2015-03-26 23:45:45 UTC
Permalink
Post by Graham Cox
Your requirement isn't clear - do you want a sheet to appear as if unattached to a host window, just floating in space? Even if you can achieve it, users will simply assume your app is buggy. Ideas like this are never seen in the wild for good reason.
I’ve been following this thread from the beginning, and have come to the conclusion that the OP was never interested in an alert or a sheet as such. I think what’s being asked for is just an anchored app- or window-modal floating panel that displays an error message. There really isn’t a standard UI element of this kind (that I can think of). The nearest would be a non-dismissable popover anchored at the point of the error.

If the intention is that the “alert” should be app-modal, then a modal NSAlert window has the correct behavior, but there are consistency reasons for not moving it from its standard position.

If the intention is that the “alert” should be window-modal, and positioned relative to the window, then a sheet with custom positioning (window:willPositionSheet:usingRect:) would have the correct behavior, but AFAIK custom sheet positioning is basically never done. (And I don’t know that you can force custom positioning on a NSAlert sheet.)

Without knowing more context, I’m not sure NSPopover is the right thing either. If not, it probably ought to be some kind of custom NSPanel.

_______________________________________________

Cocoa-dev mailing list (Cocoa-***@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/gegs%40ml-in.narkive.net

This email sent
Graham Cox
2015-03-27 00:10:44 UTC
Permalink
Post by Quincey Morris
Without knowing more context, I’m not sure NSPopover is the right thing either. If not, it probably ought to be some kind of custom NSPanel.
One situation I think would be a suitable candidate for a custom-positioned alert (or popover) is when a text field fails validation. At the moment, there's little support for handling this gracefully - I think the default response is to beep and refuse losing first responder status. It's pretty poor, in that it doesn't give the user any clue as to what they've done wrong, and beeping is such a passive-aggressive means of signalling a problem - "You're a moron, but try and guess why, ha-ha!".

A nicely positioned alert with a popover-style triangle that indicates the field in question with some explanation of the problem would be a lot better. I could be staged, so that it only appears on the second fail, etc. Of course some way to turn it off would also be needed, so that a user who has got used to the various reasons for failure won't be bombarded with messages when a beep is sufficient to remind them.

Of course I've no idea whether this is what the OP's requirement is, he doesn't say.

--Graham



_______________________________________________

Cocoa-dev mailing list (Cocoa-***@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/gegs%40ml-i
d***@gmail.com
2015-03-27 00:23:16 UTC
Permalink
Post by Graham Cox
Post by Quincey Morris
Without knowing more context, I’m not sure NSPopover is the right thing either. If not, it probably ought to be some kind of custom NSPanel.
One situation I think would be a suitable candidate for a custom-positioned alert (or popover) is when a text field fails validation. At the moment, there's little support for handling this gracefully - I think the default response is to beep and refuse losing first responder status. It's pretty poor, in that it doesn't give the user any clue as to what they've done wrong, and beeping is such a passive-aggressive means of signalling a problem - "You're a moron, but try and guess why, ha-ha!".
A nicely positioned alert with a popover-style triangle that indicates the field in question with some explanation of the problem would be a lot better. I could be staged, so that it only appears on the second fail, etc. Of course some way to turn it off would also be needed, so that a user who has got used to the various reasons for failure won't be bombarded with messages when a beep is sufficient to remind them.
Of course I've no idea whether this is what the OP's requirement is, he doesn't say.
--Graham
Sheets are used if you're using NSFormatters or Bindings aren't they?

Agreed though that even that is often pretty stinky compared to what we are used to with good web forms for example.

I believe this sheet position API is intended for things like custom borderless windows where AppKit couldn't guess where it should go.
Post by Graham Cox
_______________________________________________
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
https://lists.apple.com/mailman/options/cocoa-dev/dangerwillrobinsondanger%40gmail.com
_______________________________________________

Cocoa-dev mailing list (Cocoa-***@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/gegs%40ml-in.narkive.net

This email sent to ***@m
Quincey Morris
2015-03-27 00:27:22 UTC
Permalink
One situation I think would be a suitable candidate for a custom-positioned alert (or popover) is when a text field fails validation. At the moment, there's little support for handling this gracefully - I think the default response is to beep and refuse losing first responder status. It's pretty poor, in that it doesn't give the user any clue as to what they've done wrong, and beeping is such a passive-aggressive means of signalling a problem - "You're a moron, but try and guess why, ha-ha!”.
IIRC the HIG suggests you leave space in your window layout so that you can display an icon and a brief error message in the window itself. OTOH beep-and-refuse is a venerable tradition, and what customer has ever resented being treated like a moron?

http://www.cartoonbuddyblog.com/2010/05/hit-any-key-to-continue-english-cartoon.html <http://www.cartoonbuddyblog.com/2010/05/hit-any-key-to-continue-english-cartoon.html>
A nicely positioned alert with a popover-style triangle that indicates the field in question with some explanation of the problem would be a lot better.
Yup.



_______________________________________________

Cocoa-dev mailing list (Cocoa-***@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/gegs%40ml-in.narkive.net

This email sent to ge
Shane Stanley
2015-03-27 01:08:52 UTC
Permalink
Post by Quincey Morris
AFAIK custom sheet positioning is basically never done. (And I don’t know that you can force custom positioning on a NSAlert sheet.)
FWIW, you can -- I do it. (Think of a deep-ish document window divided into top and bottom sections, and the user is doing stuff in the bottom part -- it makes more sense, it seems to me, to have the alert appear from the top of the bottom view than at the top of the window.)
--
Shane Stanley <***@myriad-com.com.au>
<www.macosxautomation.com/applescript/apps/>


_______________________________________________

Cocoa-dev mailing list (Cocoa-***@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/gegs%40ml-in.narkive.net

This email sent
Scott Ribe
2015-03-27 01:55:31 UTC
Permalink
Post by Shane Stanley
FWIW, you can -- I do it. (Think of a deep-ish document window divided into top and bottom sections, and the user is doing stuff in the bottom part -- it makes more sense, it seems to me, to have the alert appear from the top of the bottom view than at the top of the window.)
I do it too. Be warned, starting with Mavericks things went wacko-batshit stupid if the sheet is near the screen bounds...
--
Scott Ribe
***@elevated-dev.com
http://www.elevated-dev.com/
https://www.linkedin.com/in/scottribe/
(303) 722-0567 voice






_______________________________________________

Cocoa-dev mailing list (Cocoa-***@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/gegs%40ml-in.narkiv
Shane Stanley
2015-03-27 02:47:45 UTC
Permalink
Post by Scott Ribe
Be warned, starting with Mavericks things went wacko-batshit stupid if the sheet is near the screen bounds...
My app is 10.9 and later only, but I think I'm mostly protected by virtue of a minimum size for that splitview subview. (My use of it elsewhere with an open panel is more problematic, however. I just can't think of anything better.)

And full-screen mode just puts them back at the top of the window regardless.
--
Shane Stanley <***@myriad-com.com.au>
<www.macosxautomation.com/applescript/apps/>


_______________________________________________

Cocoa-dev mailing list (Cocoa-***@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/gegs%40ml-in.narkive.net

This email sent
Continue reading on narkive:
Loading...