nspanel

In Catalina, `orderFront:` causes app to become the active application; how do I prevent this?

末鹿安然 提交于 2021-02-11 15:45:05
问题 I have a background "monitoring" app that runs either as an accessory or as a regular app (user choice depending on whether they want to see it in the dock). The app has several never-key utility windows ( NSPanel s) that display the progress of background tasks. When a background task starts, the window is made visible using orderFront: . This has worked great for years; the window would simply appear somewhere behind the active app. Starting in Catalina (macOS 10.15), however, orderFront:

Allow an NSWindow (NSPanel) to float above full screen apps

 ̄綄美尐妖づ 提交于 2021-02-06 12:48:26
问题 I'm trying to add a little window that provides "quick input" from any place in the system to the main app. The user could hit a hotkey, the window pops up, and floats above all other windows. For the most part, this isn't much of a problem. I can configure an NSWindow to be: level = Int(CGWindowLevelKey.TornOffMenuWindowLevelKey.rawValue) collectionBehavior = .CanJoinAllSpaces I can also make it an NSPanel with NSNonactivatingPanelMask option set. The only problem is: how can I make it so

Custom Sheet : can't click buttons

戏子无情 提交于 2019-12-12 02:27:27
问题 I used this source http://www.cats.rwth-aachen.de/library/programming/cocoa to create my custom sheet. I created a NSPanel object in existing .xib file and connected with IBOutlet My source code: .h @interface MainDreamer : NSWindow <NSWindowDelegate> { ... NSPanel *newPanel; } ... @property (assign) IBOutlet NSPanel *newPanel; .m @dynamic newPanel; ... //this method is wired with button on main window and calls a sheet - (IBAction)callPanel:(id)sender { [NSApp beginSheet:newPanel

set NSWindow focused

て烟熏妆下的殇ゞ 提交于 2019-12-10 19:34:41
问题 I have an app winth one window and one panel, attached to this window. steps: deactivate my app (app opened, but without the focus) click on a button on panel (panel is focused now, but main window is not) How to set focus to the main window (parent window) from the panel? 回答1: It is not clear what you mean by focus, and whether what you call main window is a main window as defined in Cocoa. Assuming it is a Cocoa main window and focus is the same as key status, [[NSApp mainWindow]

NSSavePanel crashes on Yosemite

核能气质少年 提交于 2019-12-10 17:26:51
问题 I am using NSSavePanel to save image. I have used IKSaveOption which gets added to the NSSavePanel. When save panel tries to open the sheet for window it crashes saying - *** Assertion failure in -[IKSaveOptionsContainer _didChangeHostsAutolayoutEngineTo:], /SourceCache/AppKit/AppKit-1343.14/Layout.subproj/NSView_Layout.m:577 - Should translate autoresizing mask into constraints if _didChangeHostsAutolayoutEngineTo:YES. I am following this code: NSSavePanel *savePanel = [NSSavePanel savePanel

How to create a NSPanel modally popuped from NSWindow (Cocoa programming)

一笑奈何 提交于 2019-12-06 07:08:45
问题 like NSPanel displayed after a button clicked in the NSWindow. I looked for a lot but there is no simple example. Thanks for any help. 回答1: It can be done like this: -(IBAction)showButtonAction:(id)sender { [[NSApplication sharedApplication] beginSheet:panelOutlet modalForWindow:self.window modalDelegate:self didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) contextInfo:nil]; } Attention: Don't forget to uncheck NSPanel 's Visible At Launch checkbox in Attributes Inspector and

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

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

荒凉一梦 提交于 2019-12-02 17:07:31
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 time: (In case you’re new to the concept: When a window, usually a panel, runs modal, it prevents some other part of the app from responding until it has been dismissed.) “ModalForWindow” means different things in different circumstances. If you are using loadNibNamed to display a panel defined by a xib and you want it to run modal, call this once it is displayed: // Make

EXC_BAD_ACCESS invoking a block

女生的网名这么多〃 提交于 2019-12-01 09:20:57
UPDATE | I've uploaded a sample project using the panel and crashing here: http://w3style.co.uk/~d11wtq/BlocksCrash.tar.gz (I know the "Choose..." button does nothing, I've not implemented it yet). UPDATE 2 | Just discovered I don't even have to invoke anything on newFilePanel in order to cause a crash, I merely need to use it in a statement. This also causes a crash: [newFilePanel beginSheetModalForWindow:[windowController window] completionHandler:^(NSInteger result) { newFilePanel; // Do nothing, just use the variable in an expression }]; It appears the last thing dumped to the console is

EXC_BAD_ACCESS invoking a block

北慕城南 提交于 2019-12-01 06:14:54
问题 UPDATE | I've uploaded a sample project using the panel and crashing here: http://w3style.co.uk/~d11wtq/BlocksCrash.tar.gz (I know the "Choose..." button does nothing, I've not implemented it yet). UPDATE 2 | Just discovered I don't even have to invoke anything on newFilePanel in order to cause a crash, I merely need to use it in a statement. This also causes a crash: [newFilePanel beginSheetModalForWindow:[windowController window] completionHandler:^(NSInteger result) { newFilePanel; // Do