nsalert

Make a NSAlert the topmost window?

随声附和 提交于 2020-01-01 08:53:43
问题 I've created the main window in my application to have these settings: [self setLevel:kCGDesktopWindowLevel + 1]; [self setCollectionBehavior: (NSWindowCollectionBehaviorCanJoinAllSpaces | NSWindowCollectionBehaviorStationary | NSWindowCollectionBehaviorIgnoresCycle)]; It's a very custom window that sort of floats above the desktop. In addition, it's a menu-bar application ( LSUIElement ). Alright, so I need to display an alert if something isn't right. Here's how I'm doing it: NSAlert *alert

NSImage returns nil even when png file is in Resource folder

时光总嘲笑我的痴心妄想 提交于 2019-12-24 05:06:35
问题 I'm trying to load an image using NSImage imageNamed: method but i have no success i have copied the image in the project folder: Project>Resources and added to the project using: "Add files to project ..." NSImage* image = [NSImage imageNamed:@"logosH"]; if (image == nil){ NSLog(@"NULL :/"); } NSImageView *accessory = [[NSImageView alloc] initWithFrame:NSMakeRect(0,0,200,55)]; [accessory setImageScaling:NSScaleToFit]; [accessory setImage:[NSImage imageNamed:@"logosH.png"]]; [myAlert

UIAlertView Pops Up Three Times per Call Instead of Just Once

时间秒杀一切 提交于 2019-12-24 02:45:34
问题 I am getting odd behavior from an NSAlert in two different parts of my program. The behavior is: Alert appears and then spontaneously disappears. Alert reappears and then remains until dismissed by user i.e. normal behavior. Alert reappears again. This behavior only occurs the first time the method that displays the alert is called. After that first time, it behaves normally. Here is the code for the one of the parts in which the behavior occurs: UIAlertView * locationAlert = [[UIAlertView

NSAlert resize window

亡梦爱人 提交于 2019-12-18 06:59:52
问题 I have several NSAlert dialogs with different text. I want to adjust the alert window width to the text, so that the text don't wrap. Therefore I use this code to calculate the width of the string: NSSize size = [myString sizeWithAttributes:@{NSFontAttributeName: [NSFont systemFontOfSize:[NSFont systemFontSize]]}]; Then I try to adjust the window of the alert: NSAlert *alert = [NSAlert alertWithMessageText:... ... NSPanel *panel = alert.window; NSRect frame = panel.frame; float x = (

Creating a fully customized NSAlert

喜夏-厌秋 提交于 2019-12-17 20:21:05
问题 Is it possible to create a fully customized alert? I'm doing it with custom sheets now, but I'd like to have the feature that the sheet is blocking (like -[NSAlert runModal] ). I just want to change the background, really, and the text color, of course. 回答1: Warning about the recommended solution: This code causes wasteful and pointless overhead: for (;;) { if ([NSApp runModalSession:session] != NSRunContinuesResponse) break; } This code is copied straight from the Apple documentation page -

NSAlert for right to left languages (reversed layout)

こ雲淡風輕ζ 提交于 2019-12-12 04:53:53
问题 I want to create localized NSAlert for right to left language like Arabic and Hebrew. How can I reverse the layout so that Icon is on the right, TextField on the left, and also buttons start from the left side of the alert? I can't seem to find the proper answer anywhere. Thanks, N 回答1: Apple has a Human Interface Guidelines that are somewhat strict about the ordering & placement of things. For example, in the "Place buttons appropriately" section of this HIG documentation, buttons most

Set level for NSAlert in Cocoa

南楼画角 提交于 2019-12-12 00:26:23
问题 In my application I've subclassed the NSWindow and set the window level as 25. Since the window level is 25 the alert box and error dialog box were being hidden by the window. Is there any chance to set the level of NSAlert 回答1: First of all. You shouldn't use magic numbers like 25. There is a way to set window level but it's useless because runModal uses fixed windowLevel constant kCGModalPanelWindowLevel which is 8. You can verify it like this: [self.window setLevel:25]; NSAlert *alert =

Can an Xcode Source Editor Extension prompt the user for input?

主宰稳场 提交于 2019-12-11 15:52:19
问题 Simple question. I've written an Xcode Source Editor Extension and as part of one of my commands, I have to prompt the user for input to know which option they want. I'm hoping there's a simple way to present an alert, but I'm guessing that's not the case and I'll have to instead launch the app from the extension (via URL schemes), then use inter-process communications. Like I said, hoping I'm wrong. So am I? 回答1: There is no way to prompt the user. I wanted something similar where I wanted

Make a NSAlert the topmost window?

≡放荡痞女 提交于 2019-12-04 02:44:15
I've created the main window in my application to have these settings: [self setLevel:kCGDesktopWindowLevel + 1]; [self setCollectionBehavior: (NSWindowCollectionBehaviorCanJoinAllSpaces | NSWindowCollectionBehaviorStationary | NSWindowCollectionBehaviorIgnoresCycle)]; It's a very custom window that sort of floats above the desktop. In addition, it's a menu-bar application ( LSUIElement ). Alright, so I need to display an alert if something isn't right. Here's how I'm doing it: NSAlert *alert = [NSAlert alertWithMessageText:@"" defaultButton:@"" alternateButton:@"" otherButton:@""

Tips on NSApp’s ModalForWindow, NSAlert’s ModalForWindow, and ModalSession [closed]

倾然丶 夕夏残阳落幕 提交于 2019-12-03 03:37:58
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . It took me quite a bit of experimentation to clear up some confusion over Objective-C’s “ModalForWindow” language and, subsequently, how to use a modal session. Maybe the following tips will save somebody some