开发者

How to keep NSPanel within NSScreen visibleframe always

开发者 https://www.devze.com 2023-03-22 18:26 出处:网络
I have one floating NSPanel in my a开发者_Go百科pp, which user can move using mouse. I want my NSPanel to always visible within main screen. I want code to reposition my NSPanel with its original widt

I have one floating NSPanel in my a开发者_Go百科pp, which user can move using mouse. I want my NSPanel to always visible within main screen. I want code to reposition my NSPanel with its original width and height within screen border in all the sides.

Thanks,


Subclass NSPanel and override the frame-relative methods. setFrameOrigin:, setFrame:display: and maybe others (see the documentation to find out all the methods). There is also promising - (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen method.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号