cocoa

addGlobalMonitorForEventsMatchingMask not working

笑着哭i 提交于 2020-01-29 03:00:18
问题 I am having trouble with getting an assistive-enabled application (XCode in the development case) to capture global keyDown events. I've seen lots of code examples like the below, but this doesn't work for me on 10.9.4. #import <AppKit/AppKit.h> #import <Foundation/Foundation.h> // 10.9+ only, see this url for compatibility: // http://stackoverflow.com/questions/17693408/enable-access-for-assistive-devices-programmatically-on-10-9 BOOL checkAccessibility() { NSDictionary* opts = @{(__bridge

NSTextField enter to trigger action

折月煮酒 提交于 2020-01-28 05:40:46
问题 I've been looking all over for a simple example of how to have an action (or button) be triggered when the enter key is hit in the text field. Should I subclass the text field? Would I need to set a delegate to call the action I need? Is there a way to catch the event in my main window controller class? If you could even just point me to the right direction that would be great. Thanks. 回答1: To get action after you hit enter just write an IBAction in your window controller and connect to your

Objective C naming convention for method performs an action and returns a value

女生的网名这么多〃 提交于 2020-01-26 03:14:07
问题 I have a method that performs an action and returns a value. For example from the input number it will update class's input history, then generate and return an input record. So how do I name this method? I think even C has this problem, e.g. fopen function does open a file and return a handler. But with Objective C convention it seems difficult to name the method. From apple document for cocoa name convention and also from this article cocoa with love They both said " If a method performs an

Maverick Issue : While adding a subview on NSView

爱⌒轻易说出口 提交于 2020-01-25 11:44:04
问题 I have a NSView(outlet - detailsView) , upon that a NSSplitView (outlet - detailsSpiltView) and there are two subviews in the split view and in those subview there are different scroll view and table view. NSView(detailsView) | NSSplitView(detailsSplitView) | | NSView NSView | | NSScrollView NSScrollView | | NSTableView NSTableVIew On a certain condition I am adding a an error view on detailsView and on other conditions the table view would be populated: The code for loading errorView is the

NSButton setImage not working

半城伤御伤魂 提交于 2020-01-25 10:37:08
问题 I am trying to change the image of my nsbutton for my application. I have searched and found a couple of ways to do so but none of them are working for me at the moment. I have looked at the following solutions : How to set NSButton background image Using -setImage on NSButton I have a routine that is called when I click the button : - (IBAction)pauseResumeButtonAction:(id)sender { IAgentInterface* agentInterface = ioc::Container::Resolve(); if (self.pauseResumeSwitch == PauseResumeSwitch:

Is possible to do a custom binder on an array of input fields using RxSwift?

时光总嘲笑我的痴心妄想 提交于 2020-01-25 10:13:51
问题 I have two input fields, one for password and another one to confirm the password. I want to create a custom binder that will allow me to compare the value of both input fields but also validate minimum amount of chars. I had a pretty similar question but not regarding comparing two different fields (Is there some sort of Priority operator on RxSwift?) and based on the answer for that previous question I've been trying to do something like this: enum PasswordCreateValidation { case valid case

How to change the tint colour of NSSwitch?

喜欢而已 提交于 2020-01-25 07:26:10
问题 The NSSwitch looks right now pretty pale: I'm trying to change the tint colour like this on iOS: But there is no tint colour section on IB like it is on iOS. So I'm trying my luck in the code: @IBOutlet weak var alwaysConnectedSwitch: NSSwitch! override func viewWillAppear() { super.viewWillAppear() self.alwaysConnectedSwitch.layer?.backgroundColor = CGColor.init(gray: 1, alpha: 1) } But the self.alwaysConnectedSwitch.layer seems to be nil, so nothing is set. 回答1: If you absolutely need to

NSView overlay passes mouse events to underlying subviews?

你。 提交于 2020-01-25 06:18:11
问题 I have a loading overlay which is supposed to block all the AppKit Controls off untill loading is done. However the view seems to be passing all the mouse events to the underlying layers. How to disable that? 回答1: I suggest using a child window instead. 来源: https://stackoverflow.com/questions/3522410/nsview-overlay-passes-mouse-events-to-underlying-subviews

continue tracking mouse-drag event even after cursor moves out of the movie

▼魔方 西西 提交于 2020-01-25 02:52:28
问题 I have few views aligned in grids in parent view (All being NSView's ) I am overriding -(void)mouseDown:(NSEvent *)event - (void)mouseDragged:(NSEvent *)theEvent for some custom drawing in child view subclass To be specific, I draw some rectangle boxes during mouse drag in child view's. Problem: when cursor moves out of the child view( during mouse drag ) , obviously, I am not able to track the event and hence I cannot resize the rectangle. I want to track the mouse movements even outside the

Using [[NSRunLoop currentRunLoop] runUntilDate:[NSDate date]] to let the scheduled selectors fire

允我心安 提交于 2020-01-25 01:58:07
问题 In my application at some point I have a bunch of messages scheduled using performSelector . Under some conditions, while handling an UI action, I need to wait for all the currently scheduled selectors to fire. I could place my code in another method and schedule it using performSelector:target:argument:order:modes: with order value high enough to be sure it will fire last, but there are reasons why I think that would make an ugly solution. So I send [[NSRunLoop currentRunLoop] runUntilDate: