简体   繁体   English

与iCal相似的可可弹出式窗口

[英]Cocoa Pop-up Window Similar to iCal

I want to open an overlay window (pop up window) when a user selects a cell in my NSTableView similar to selecting an event in iCal. 当用户在我的NSTableView选择一个单元格类似于在iCal中选择一个事件时,我想打开一个覆盖窗口(弹出窗口)。 Selecting the event in iCal shows a Window to edit the event, but does so by smoothly animating the window open and adding an arrow pointing to the even in the underlying calendar. 在iCal中选择事件会显示一个窗口来编辑事件,但是可以通过平滑地使窗口打开动画并在底层日历中添加指向偶数的箭头来进行编辑。 Does anyone know what is being used here? 有人知道这里使用了什么吗? Is this a bunch of hidden/custom APIs or is this available for public use? 这是一堆隐藏的/自定义的API还是可供公众使用?

The editor pane appears to be a custom borderless, transparent window with a custom view (the view defines the shape and therefore the shadow it casts). 编辑器窗格看起来是带有自定义视图的自定义无边界透明窗口(该视图定义了形状并因此定义了其投射的阴影)。 Learn more here . 在这里了解更多。 You might even use MAAttachedWindow . 您甚至可以使用MAAttachedWindow

Regarding animation, it's as simple as asking the window's animator to animate the frame and the alpha value (grouping them together). 关于动画,这就像要求窗口的动画师为帧和alpha值设置动画(将它们分组在一起)一样简单。 You'll probably want to set everything up directly in its "start position" first (ie, while the window is off-screen, set its alpha to zero, and its frame to some smaller version so it "zooms in" a la iCal), then put it on screen and start the grouped animation: 您可能需要先将所有内容直接设置在其“开始位置”(即,当窗口不在屏幕上时,将其alpha设置为零,并将其框架设置为一些较小的版本,以便“放大” la iCal ),然后将其放到屏幕上并开始分组动画:

[NSAnimationContext beginGrouping];
[[window animator] setFrame:someNewSlightlyLargerFrame];
[[window animator] setAlphaValue:1.0];
[NSAnimationContext endGrouping];

Once the grouping is ended, the animation will begin (asynchronously) and your code execution will continue. 分组结束后,动画将开始(异步),并且您的代码将继续执行。 Something to think about is getting everything "staged" first (including making sure the subviews of your window are already updated beforehand, so they don't change in the middle of your animation ... unless you want them to). 要考虑的是首先使所有内容“上演”(包括确保窗口的子视图已经预先更新,因此它们不会在动画的中间发生变化……除非您希望这样做)。

So the two separate techniques you need to understand are a custom window and basic Cocoa animation. 因此,您需要了解的两种独立技术是自定义窗口和基本的可可动画。

如果您使用的是OSX 10.7及更高版本,则NSPopover将完成您要寻找的工作。

Are you talking about selecting even from a list at the bottom of iCal app? 您是在谈论甚至从iCal应用程序底部的列表中进行选择吗?

Not sure what exactly you are referring to but there is an api for animating transformations within a timespan. 不知道您确切指的是什么,但是有一个用于在时间跨度内对转换进行动画处理的api。

Looking at other Apple's applications, Apple's developers utilize the same api available to anyone else (mostly I guess). 看看其他Apple的应用程序,Apple的开发人员会使用其他任何人都可以使用的相同api(我猜大部分是这样)。 There is lots of stuff that can be customized and Apple customizes whatever is required until it looks right from design point of view ... 有很多东西可以自定义,Apple可以自定义所需的一切,直到从设计的角度看起来很合适为止。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM