I want to trigger a button on left mouse down in my mac osx app using swift.
This is the way to do it in Objective-C
[myButton sendActionOn:NSLeftMouseDownMask];
I can't figure out how to do it in Swift. Can anybody help me out with my problem?
Thanks!
After a bit of fiddling in Xcode, this is what worked for me (Swift 2.0):
myButton.sendActionOn(Int(NSEventMask.LeftMouseDownMask.rawValue))
Related
I want to write a MacOS Cocoa Desktop App with XCode 10 and Swift 4.2.
It should have a searchfield with a suggestions view opening as you keep typing like Google Search or Spotlight with autocompletion.
However I'm completely new to Cocoa programming.
I have already tried to add an NSSearchField and a dynamically added NSPopOver object with subclass of NSTableView which contains all the suggestions. But I am not happy with the suggestions view because of the anchor/arrow that appears with it. It seems like it breaks the UI guidelines.
Thus I have tried to implement my own custom subclass of NSView containing the suggestions. It works fine but I struggle with simple things like making it hide/disappear as soon as any other area is clicked in the app.
Does anyone know a good example as best practice for this task or have some sample code?
I have an app that runs fine inside of Xcode 6.3 that is running on MacOS X 10.5. When I copied this same program code to another Mac machine that is running EL Capitan v. 10.11.5 and Xcode 7.3.1, prepareForSegue will display a modal transition versus its configured "Show (e.g. Push)"!
I deleted the UINavigationController, and then reinstituted it by "embedding" it via the tableViewController. I also reestablished the "Show (e.g. Push)" Storyboard Segue Kind between the initial view controller, and the UINavigationController. Unfortunately, the transition is alway a Modal segue (the tableviewController opens from the bottom of the screen).
Please help me with this issue! Any suggestions would be greatly appreciated! Thank you
Xcode 4.2 used to toggle between the header file and the .m file when you swiped up/down with 3 fingers in an editor window. Now excode 4.4.1 turns it into a text selection. Is there a way to change the default behavior to something else (in my case back to toggling between .h/.m)?
I got the 3 finger swipe working in Xcode 4.4 (I'm running Mountain Lion). It is possible. Try following these instructions: https://stackoverflow.com/a/7923619/472344.
I had already used these to get the 3 finger swipe working in Xcode 4.3 when I updated to Lion. It seemed to break when I updated to Xcode 4.4 and Mountain Lion. I went through all the steps again, but this time all the settings were already set correctly so I didn't have to change anything. However, now it's working for me. Give it a shot.
You can also switch between the .h and .m by using ctrl+command+UpArrow (or DownArrow).
I don't know if there is a way to change the gesture within Xcode, but usually i find if i open .h first, then .m (or the other way around) then you can swipe between them with 2 fingers right or left :)
As long as you open them in the centre and not in a new window =]
Is the semi-transparant notification window which XCode 4 shows on Snow Leopard and on Lion a standard Cocoa control or is it something custom? I've seen more and more apps with similarly styled popups, and don't want to go about reinventing something if a much cleaner implementation exists in Cocoa. If this is a standard control, could someone tell me the name or point me to the documentation for it?
This is the popup window I am referring to:
This is custom but Matt Gemmell has sample code at http://mattgemmell.com/source. It's called RoundedFloatingPanel.
In my Mac application I'd like to implement a view that simulates UITabBar from iOS.
What's the preferred way to implement this? Use NSOutlineView , NSTableView, or something else?
For a native Mac app, the equivalent of a UITabBar is an NSTabView. If you want to go for the iOS look, you either have to roll your own with some NSView subclass or take a look at UMEKit.
Chameleon may also be an option, but it currently doesn't implement UITabBar, this might change in the future.
If you want to follow a trend of making your Mac app with the UIKit look-and-feel
you might want to take a look at the Chameleon Project - note the status of the project on the developer's blog. However, the project source is on github now, and people are helping out.