cocoa

Click on button i.e. .Activated not invoked once OrderOut is called

回眸只為那壹抹淺笑 提交于 2021-01-29 19:24:07
问题 The Button.Activated or Button's Action is not getting called for some reason, which I can not find. The code goes like this. In the ViewController's constructor: _whenActivated = this.WhenActivated(x => SetupBindings(x)); Then have a methods: private void SetupBindings(CompositeDisposable disposables) { this.BindCommand(ViewModel, vm => vm.ContinueCommand, v => v._loginButton) .DisposeWith(disposables); Observable.FromEventPattern( h => _cancelButton.Activated += h, h => _cancelButton

How to rotate text in NSView? (Mac OS, Cocoa, Swift)

元气小坏坏 提交于 2021-01-29 18:27:32
问题 I am new to Cocoa/Swift applications for Mac OS 10.11 (Not iOS). I created an NSView with the size of A4 paper, drew some simple lines and some text using NSString.drawAtPoint within drawRect() . So far it works. However, from time to time, I need a few characters to be turned 90 degrees, and some text needs to be scaled at X, or Y direction. That is where I don't know how to do it. Please can someone tell me how to achieve these? Many thanks. 回答1: You can use NSAffineTransform . This code

Use cocoa bindings and threads

末鹿安然 提交于 2021-01-29 11:23:48
问题 I have a few labels bound to a few variables that are modified in other threads via GCD. Now I've read that cocoa bindings are not thread safe but my app is running fine (the UI updates when the values of the variables are updated in a background thread) Would it be the correct way to do the calculations in the background thread and if I need to change the variable value make this via DispatchQueue.main.sync() { self.variable = newValue } ? If cocoa bindings are not thread safe, why I never

What happed when we excute NSTimer invalidate?

微笑、不失礼 提交于 2021-01-29 09:30:43
问题 self.timer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(timeCall:) userInfo:self.strong repeats:YES]; [self.timer invalidate]; NSLog(@"%p",[self.timer userInfo]); Then app crashes because EXC_BAD_ACCESS . Apple document says, This method is the only way to remove a timer from an NSRunLoop object. The NSRunLoop object removes its strong reference to the timer, either just before the invalidate method returns or at some later point. If it was configured with

NSMenuItem with custom view disappears while scrolling

五迷三道 提交于 2021-01-29 07:27:11
问题 I implement a NSMenu with NSMenuItem and set custom view to it. When menu is scrollable, mouse hovering on ▼ button to scroll will cause some menuItem disappear (or not draw correctly). Hope someone give me some help. I will appreciate that. Here's video about this issue: https://streamable.com/obrbon Here's my code: private func setupMenuItemView(_ menu: NSMenu) { let menuItemHeight: CGFloat = 20 let menuWidth = frame.width let textFieldPadding: CGFloat = 10 for menuItem in menu.items {

Set background image NSToolbar

一笑奈何 提交于 2021-01-29 04:40:51
问题 I am relatively new to OS X app development and I'm wondering if it possible to put a background image to a NSToolbar, such as in Game Center.app or Calender.app(iCal.app)? I have looked around and can't find anything on here or on google. It occured to me that there might not be a public API and it might be private. My app will not be submitted to Apple's Mac App Store, so I am able to use private APIs(if necessary). If anybody knows the API, I would be more than grateful! Thank you so much

How do I disable or remove the “replace” checkbox of NSTextFinder?

試著忘記壹切 提交于 2021-01-28 18:35:12
问题 My app displays a logfile in an NSTextView . I want the user to be able to search the output using the find bar, but not be able to replace any text. The NSTextView is set to be not editable, but when I press cmd-F, the find bar shows a "replace" checkbox: I can prevent the user from being able to actually replace any text by implementing the NSTextViewDelegate protocol methods textView:shouldChangeTextInRange:replacementString: and textView:shouldChangeTextInRanges:replacementStrings: but

Running terminal commands in in cocoa app

不问归期 提交于 2021-01-28 14:53:35
问题 I facing a problem when running my code on cocoa app to run some command line scripts This function run smoothly when using Command line tool but when using full cocoa app with some On Off UI it not working at all My script should turn on/off the http & https proxy Here is my function: private func runTask(_ cmd: String) { // Create a Task instance let task = Process() // Set the task parameters task.launchPath = "/bin/sh" task.arguments = ["-c", String(format:"%@", cmd)] // Create a Pipe and

NSStatusItem “kCG…” Errors

你说的曾经没有我的故事 提交于 2021-01-28 12:03:14
问题 For some reason, in the Console I'm getting : kCGErrorIllegalArgument: CGSUnregisterWindowWithSystemStatusBar: Invalid window : kCGErrorFailure: Set a breakpoint @ CGErrorBreakpoint() to catch errors as they are logged. with (I think) this code ... - (void)applicationDidResignActive:(NSNotification*)aNotification { statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength]; [statusItem setHighlightMode:YES]; [statusItem setEnabled:YES]; //Set menubar item's

Cocoa: Youtube video does not support full screen in WKWebview

泪湿孤枕 提交于 2021-01-28 08:01:58
问题 I’m making a web browser using Xcode, I played with the browser then relized the it dosn’t play full screen youtube video’s and embeded videos. I have tried this code... let webViewConfiguration = WKWebViewConfiguration() webViewConfiguration.allowsInlineMediaPlayback = false WKWebView(frame: .zero, configuration: webViewConfiguration) But it says Wkwebview has no member of allowsInlineMediaPlayback. This is an image of what youtube shows Here is my code for more detail… import Cocoa import