问题标签 [nsopenpanel]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
cocoa - 从 beginSheetModalForWindow 获取 URL:
我正在使用 OpenPanel 来获取文件路径 URL。这有效:
这不会,导致“分配只读变量”错误:
通常,从 oPanel 的上下文中提取 pathToFile 的任何尝试都失败了。这对于小情况来说并不是什么大问题,但是随着代码的增长,我不得不将所有东西——XML 解析、核心数据等——塞进一个不合适的区域。我该怎么做才能提取 pathToFile?
谢谢。
objective-c - 打开面板出现然后立即消失
我正在使用这段代码:
这是该方法中唯一的代码。调用该方法时,打开的面板会在屏幕上显示一秒钟然后消失。我该如何防止这种情况?
谢谢。
cocoa - Determine when a NSOpenPanel will close
I'm trying to determine when an NSOpenPanel is closing before it actually closes. I need to do this so I can overlay another window with a screenshot of the open panel on top of it to be animated. Unfortunately, all the notifications that you seem to be able to access seem to fire AFTER the window's already been closed. This leads to a jarring stutter before you start your transition.
I've tried:
- using NSWindow delegate methods on the open panel (apparently, none of the NSWindow delegate methods work)
- monitoring panel:userEnteredFilename:confirmed: (not called)
- showing the dialog with a callback (callback happens AFTER the panel disappears)
cocoa - 更改 NSOpenPanel (Cocoa OSX) 的取消按钮的文本
我想要一个可定制的选择器,可以定制许多功能。我不知道该怎么做的一件事是更改取消按钮的文本。我发现setPrompt方法会改变okay按钮的文字,但是我找不到cancel按钮的类似方法,有没有这样的方法?
objective-c - NSOpenPanel setAllowedFileTypes
我有一个 NSOpenPanel。但我想让它只能选择 PDF 文件。我正在寻找类似的东西:
我希望有人有一个解决方案。
c++ - 来自 C++ 增强线程的 NSOpenPanel
我正在从 boost C++ 创建的线程调用 NSOpenPanel。
面板行为不规律并且对鼠标的响应不佳,即单击对象有时在单击顶级组合框时不会提高响应。
我要运行一个单独的运行循环吗?我正在运行一个 runModalForDirectory,它应该负责运行它自己的循环。
我还创建了一个单独的 objc 类,该类执行 performSelectorOnMainThread 以在主线程中显示面板,但行为仍然相同。
我也尝试过使用 waitUntilDone:NO 并运行 CFRunLoopRunInMode 这也无济于事。
cocoa - 可可如何知道哪个窗口是前景
Mac OS X 上有什么类似于 GetForegroundWindow 的吗?
我有两个应用程序,一个窗口化(基于 NSDocument)和一个命令行我想从命令行工具显示一个 NSOpenPanel,并希望使其成为基于 NSDocument 的应用程序的模型,但没有 windowref 吗?
cocoa - 单击确定/取消按钮后,NSOpenPanel 是否可以配置为不关闭?
我想为关闭操作设置动画。但是,我没有任何运气弄清楚如何在单击“确定”或“取消”按钮后立即使 NSOpenPanel 从屏幕外消失。
cocoa - 选择文件/目录后立即关闭 NSOpenPanel
我是 NSOpenPanel/NSSavePanel/NSPanel 的新手。我正在使用 NSOpenPanel 选择一个目录,我的应用程序将对其文件进行迭代并进行一些相当耗时的处理。
我可以在面板上调用 -close ,但这不会将焦点返回到主窗口。我已经阅读了很多关于“关闭”面板的内容 - 但我没有找到任何“关闭”而不是“关闭”面板或窗口的方法。
只是我需要生成一个后台线程(NSOperation)吗?
这就是我的 -chooseDidEnd:returnCode:contextInfo:
虽然 NSOpenPanel 确实消失了,但我的 NSProgressIndicator 没有动画,并且主窗口直到-doLotsOfTimeConsumingWork: 完成后才会激活。
更新 刚刚查看了 NSOperationSample 代码,看起来就是这样。
objective-c - When calling to NSOpenPanel's runModal, my application will not properly terminate
I'm writing a simple Cocoa Application, no core data or multiple document support. Running on a Mac Pro, OS X 10.6.6, Xcode 3.2.3.
I have reduced my application to the following code in my AppDelegate class:
From within the debugger, I will run my application. As expected a somewhat not-to-useful OpenPanel will appear. I will click Cancel and it will disappear. All this is as expected. When I click [Command + Q] to Quit the application, the UI will go away but the debugger will indicate that the application is still running (as does the console output).
Based upon all the information I'm reading, I should not have to do anything else in order for this to run right. I've downloaded several examples on the Open Panel's usage but most use the deprecated methods of opening modal giving additional information as parameters. FWIW, I tried those methods and am still seeing the same result.
One last item, when the Open dialog appears, just for an instant I see a message box asking me something to the extent if I want my application to receive incoming connections. The dialog quickly disappears. I don't know if that is part of my problem or not. [Update - this deals with my Firewall being turned on.]
Yes, I'm fairly new at Objective C but not at programming in general. Any words of wisdom is greatly appreciated!
2011.02.07 - Update:
I have walked the debugger line by line without incident. There is no indication of any program failure in the console window.
I say that the debugger is still active after [Command + Q] because the Stop Process toolbar button is still enabled as is the Break button. Further the console indicates that after I tell the application to terminate (either via the menu or key command) that it is still running. The following is the Complete console output from start of run to after I Quit the application.
The Activity Monitor (system tool) will show my application terminating (no longer shows up as a process) but the Debugger will still not transition to "edit" mode - if I tell Xcode to run the debugger again, it will ask me if it's OK to Stop the current debugging session. If I was in Windows I would start looking for background threads keeping the process alive but as far as I know, NSOpenPanel should not be doing something like that.
I have further simplified the program to nothing more than creating a brand new Cocoa application and inserting the code snippet above - no other additions to the template project or updates in any way.
And lastly, when the application is run under the Leaks Performance Tool, everything runs fine when the panel is created but never used. When created and actually used though, at the end of the run I will get the following message in the tool "insufficient task_for_pid privileges (leakagent64)". Googling this hurts. If I read it right, the debugger does not have sufficient permissions to fully kill the target process ??? Now that sounds stupid but ... It does not make sense!
Another update - I just downloaded and ran FunHouse, one of the SDK sample applications that also uses NSOpenPanel. Well don't I feel special. It exhibits the same exact behavior. So from this I conclude either Apple has a bug in their code, my machine is special and messed up, and finally, it is Not my code that is at fault. That being the best part. Tomorrow, I will use a friends Mac and see if the same behavior is exhibited on his box.
This is just too weird.