nswindow

How to detect right and left click in cocoa

做~自己de王妃 提交于 2019-11-30 07:43:30
I want to create a action on right and left click of mouse. Click may be on NSTableViewCell, NSView, etc (Like when we right click on window it gives a pop-up ) . Is there any API to do such task? If no, any other way . Thank you in advance for helping me. Ramy Al Zuhouri You have to override NSResponder methods like: - (void) mouseDown: (NSEvent*) theEvent; - (void) rightMouseDown: (NSEvent*) theEvent; Reference: NSResponder Documentation . Update: as mentioned below, NSView and NSTableView inherits these methods from NSResponder. NSView and NSTableView inherits from NSResponder and

NSWindow textured background with NStextField

天涯浪子 提交于 2019-11-30 07:43:29
I have a super strange problem. I want a Textured window to have it normal gradient color. I have an NSTextField in this window, the text field is destined to be an URL input field so it need to be large. The problem is that when it is too large (approximately more than 1/3 of the window width) it just switch the textured window to draw a darker version of it gradient. Here is an example project (very simple...) for you to test. http://raven.ipodtutofast.com/test.zip When you will build and run it notice the background of the window, initial one is fine, now make the window bigger, it will

Get ALL views and subview of NSWindow

最后都变了- 提交于 2019-11-30 06:47:06
问题 Is there a way I can get ALL the views and subviews and subviews of these subviews (you get the idea...) of an NSWindow? Thanks. 回答1: Here is a category on NSView: @interface NSView (MDRecursiveSubviews) - (NSArray *)allSubviews; @end @implementation NSView (MDRecursiveSubviews) - (NSArray *)allSubviews { NSMutableArray *allSubviews = [NSMutableArray arrayWithObject:self]; NSArray *subviews = [self subviews]; for (NSView *view in subviews) { [allSubviews addObjectsFromArray:[view allSubviews]

Title Bar Buttons and Custom Title Bars

雨燕双飞 提交于 2019-11-30 05:27:15
I have created a custom title bar view for a blackened NSWindow (style 0), so that I can have it disappear in a similar manner to Quicktime X. The only problem is, the buttons don't respond to mouse over and mouse move actions on the title bar can get combined with pressing in the buttons. The full source code is here: https://github.com/iaefai/OrganicUI under Classes/ORTitleBar.m and ORWindow.m. The buttons are standard from this method: self.closeButton = [NSWindow standardWindowButton: NSWindowCloseButton forStyleMask:NSTexturedBackgroundWindowMask]; Then positioned: [self.closeButton

NSWindow - show new window that will always stay on top of current window

半世苍凉 提交于 2019-11-30 05:21:37
问题 I want my NSWindow to show new window(s) that will always be on top of current window. they should NOT be on top of other windows. In addition, they should not move when the original window moves. How can i do that? 回答1: Use NSWindow 's addChildWindow:ordered: or setParentWindow: method to add the other window as a child of the first window. That window will follow the first window around. See the NSWindow Class Reference. 回答2: You can set window level to NSFloatingWindowLevel so it always be

Allow click and dragging a view to drag the window itself?

◇◆丶佛笑我妖孽 提交于 2019-11-30 04:48:46
I'm using a textured window that has a tab bar along the top of it, just below the title bar. I've used -setContentBorderThickness:forEdge: on the window to make the gradient look right, and to make sure sheets slide out from the right position. What's not working however, is dragging the window around. It works if I click and drag the area that's actually the title bar, but since the title bar gradient spills into a (potentially/often empty) tab bar, it's really easy to click too low and it feels really frustrating when you try to drag and realise the window is not moving. I notice NSToolbar

Cocoa/OSX - NSWindow standardWindowButton behaving strangely once copied and added again

佐手、 提交于 2019-11-30 02:45:14
In my app I change the position of the standardWindowButtons close / miniturize / expand like so: //Create the buttons NSButton *minitButton = [NSWindow standardWindowButton:NSWindowMiniaturizeButton forStyleMask:window.styleMask]; NSButton *closeButton = [NSWindow standardWindowButton:NSWindowCloseButton forStyleMask:window.styleMask]; NSButton *fullScreenButton = [NSWindow standardWindowButton:NSWindowZoomButton forStyleMask:window.styleMask]; //set their location [closeButton setFrame:CGRectMake(7+70, window.frame.size.height - 22 - 52, closeButton.frame.size.width, closeButton.frame.size

How do you use the dark vibrancy on an NSWindow?

萝らか妹 提交于 2019-11-30 01:57:44
What is the correct way to use the Vibrant Dark ( NSAppearanceNameVibrantDark ) or Vibrant Light ( NSAppearanceNameVibrantLight ) modes with an NSWindow ? I'm building an application and would like to offer the new Vibrant Dark appearance as an option for the main application's NSWindow . The window itself is a pretty straight forward window with an NSToolbar across the top and a scroll view as the main content area. There's plenty of information from Apple on using the new vibrancy appearances in conjunction with an NSVisualEffectsView , but I'm looking for clarification on how to use those

How to know if a NSWindow is fullscreen in Mac OS X Lion?

北城以北 提交于 2019-11-30 01:16:47
问题 I guess I should check if [NSApplication presentationOptions] contains NSFullScreenModeApplicationPresentationOptions , but how do I achieve that? EDIT: using [NSApplication presentationOptions] doesn't work as in my document-based app there might be some documents in fullscreen and others not. I'm now looking for another solution. I'm wondering why there isn't a property called [NSWindow isFullscreen] or something like that. 回答1: I was just looking for a solution myself and based on Matthieu

Make NSView in NSPanel first responder without key window status

。_饼干妹妹 提交于 2019-11-29 21:42:02
问题 Is it possible to give an NSView inside an NSPanel first responder status without giving the NSPanel key window status (making the main application window resign key)? Thanks. 回答1: Well, I ended up figuring this one out, but it took a lot of research so I'll post the details here in case anyone else runs into the same problem. First of all, a few basics: It's impossible to have 2 windows actually be key at the same time It's possible to fake a window into thinking it's key by overriding