Cocoa

validate before leaving text field

Either this is way harder than it should be or I am missing something   I have a tab view and on some of the tabs I have text fields that I want to validate and pop an alert if they are invalid   In the textShouldEndEditing method for the fields I validate the data, and pop an alert and return false if the data is invalid. This works fine when I move to another field on the current view. If I chan... »

How to capture scroll wheel events of a subview?

My app uses an NSPageController to navigate forwards and backwards to several views with a swipe gesture.For some of this views, I am using a  WKWebView. Unfortunately The main content view cannot capture the swipe gestures of its subview, becuase of a conflicht with the scroll behaviour of the webView. I tried to subclass the WKWebView, but with no success. How could I capture the swipe events? I... »

How to invoke NSTextFinder programmatically?

I’d like to programmatically set a search string and invoke a search in an NSTextView. The NSTextFinder class provides functionality to do this, but I cannot figure out how to use it without presenting a find bar in which the user manually enters a search string.   How can I programmatically set a search string and invoke a search on an NSTextView without user intervention? Powered by WPeMat... »

Why is it recommended that “don’t provide app icons in ICNS or JPEG format.”

Below url, it is written “Don’t provide app icons in ICNS or JPEG format.” https://developer.apple.com/macos/human-interface-guidelines/icons-and-images/app-icon/   I have a question about why it is not allowed about .icns.   My previous macOS app’s app icons is in a icns file. is there any potential problem? Powered by WPeMatico »

Drawing Text over NSImage

I have the following code to draw a text over an NSImage. But the resulting image is getting cropped at the corner and only the corner portion is displayed. What i’m i doing wrong? Please advice funcdrawText(image :NSImage) ->NSImage {     let text = "sample text"     let font = NSFont.boldSystemFont(ofSize: 18)     let imageRect = CGRect(x: 0, y: 0, width: image.size.width, height: image.si... »

How to make NSWindow’s window level remain unchanged in NSApp.runmodal(for: window)?

I’m currently making an macOS app about screenshot editing. It let users to resize and drag a rect on screen and output the screenshot in that area.To achieve this, I make an overlaywindow which fill the whole screen and it’s window level is higher than app’s menu bar.     override init(contentRect: NSRect, styleMask aStyle: NSWindowStyleMask, backing bufferingType: NSBackingStor... »

Is there an easy way to tint a template NSImage?

Recently, I’ve been working with NSVisualEffectView (for the first time) and that introduced me to template images.   As I understand it, using a template image in a visual effect view will allow the image to be vibrant. This made me wonder if I could also work with template images in non-vibrant views and tint them where necessary.   For example, rather than specify separate images for the ... »

Proper use of NSDecimalNumberHandler

Morning All:   I’m using NSDecimalNumbers for arithmetic in my application. I’m having some problems with rounding. If I want to do something like:   25 / 99 * 99 – 25.  Obviously it’s a repeating decimal and there’s going to be some change left at the end of the application. After the ‘divide’, by result is:   0.252525252525252525252525252525252526   Afte... »

Reading OS X App creation date

Is it possible to read the app creation date from within the app ?   I suppose this date is set at compilation time. But, could they be modified externally, such as with a terminal command, or is it a read only value ? Powered by WPeMatico »

NSMenuItems don’t respect hidden if an alternate menu item is set

I have two menu items shown in a row in a context menu. The second item is an alternate (like how in Finder you can “Copy” or “Copy as pathname”).   In my menuNeedsUpdate: delegate method, there is a situation where it could be pointless to show these items (back to the Finder sample, if there is nothing selected to “Copy” the menu item is hidden).   So in menuD... »

Skip to toolbar