Coder Social home page Coder Social logo

cocoabits / maspreferences Goto Github PK

View Code? Open in Web Editor NEW
670.0 670.0 102.0 124 KB

Modern implementation of the Preferences window for OS X apps, used in TextMate, GitBox and Mou:

Home Page: http://blog.shpakovski.com/2011/04/preferences-windows-in-cocoa.html

License: Other

Ruby 4.03% Objective-C 93.15% Swift 2.82%

maspreferences's People

Contributors

barijaona avatar danielvy avatar fingolfin avatar flyingdiver avatar gettoset avatar iwankerl avatar jnorth avatar josh64x2 avatar jtbandes avatar kainjow avatar mattprowse avatar mz2 avatar philippb avatar robin avatar robrix avatar sorbits avatar swt2c avatar toshi0383 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

maspreferences's Issues

MASPreferences compatibility carthage?

Dear shpakovski

Now, I'm using MASPreferences & MASShortcut.
These are great projects!

MASShortcut has compatible in Carthage, But MASPreferences is not compatible.
Do you have plans for support carthage?

Thx!

Responder chain loop in OS X 10.10 (Yosemite)

Patching the responder chain causes a responder chain loop here. Yosemite automatically adds view controllers to responder chain. Simply set NSResponderDebugResponderLoops=YES for debugging and the loop will be detected.
Here is what you get:
2015-03-19 14:13:14.752 Demo[1719:20436] NSResponderDebugResponderLoops=YES
2015-03-19 14:13:18.674 Demo[1719:20436] Responder chain loop detected! Calling [NSWindow setNextResponder:] self=<NSWindow: 0x6100001e6100>, aResponder=<GeneralPreferencesViewController: 0x6100000c44b0>
2015-03-19 14:13:18.674 Demo[1719:20436] You have a loop in the responder chain: this is a programming error
2015-03-19 14:13:18.676 Demo[1719:20436](0 CoreFoundation 0x00007fff9722050c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x00007fff911ff76e objc_exception_throw + 43
2 AppKit 0x00007fff941ab088 -[NSResponder setNextResponder:] + 368
3 Demo 0x0000000100003fc1 -[MASPreferencesWindowController patchResponderChain] + 193
4 Demo 0x0000000100005725 -[MASPreferencesWindowController setSelectedViewController:] + 5157
5 Demo 0x0000000100002d9d -[MASPreferencesWindowController windowDidLoad] + 413
6 AppKit 0x00007fff943416c7 -[NSWindowController _windowDidLoad] + 586
7 AppKit 0x00007fff943299f3 -[NSWindowController window] + 110
8 AppKit 0x00007fff9433ba42 -[NSWindowController showWindow:] + 36
9 Demo 0x0000000100001fa5 -[DemoAppDelegate openPreferences:] + 85
10 libsystem_trace.dylib 0x00007fff90377cd7 _os_activity_initiate + 75
11 AppKit 0x00007fff943c9bd1 -[NSApplication sendAction:to:from:] + 452
12 AppKit 0x00007fff943df6e6 -[NSControl sendAction:to:] + 86
13 AppKit 0x00007fff943df602 __26-[NSCell _sendActionFrom:]_block_invoke + 131
14 libsystem_trace.dylib 0x00007fff90377cd7 _os_activity_initiate + 75
15 AppKit 0x00007fff943df55f -[NSCell _sendActionFrom:] + 144
16 libsystem_trace.dylib 0x00007fff90377cd7 _os_activity_initiate + 75
17 AppKit 0x00007fff943dda33 -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 2821
18 AppKit 0x00007fff944360df -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 770
19 AppKit 0x00007fff943dc0e6 -[NSControl mouseDown:] + 714
20 AppKit 0x00007fff94944b4c -[NSWindow _reallySendEvent:isDelayedEvent:] + 14125
21 AppKit 0x00007fff942d5b16 -[NSWindow sendEvent:] + 470
22 AppKit 0x00007fff942d20a2 -[NSApplication sendEvent:] + 2504
23 AppKit 0x00007fff941fbae8 -[NSApplication run] + 711
24 AppKit 0x00007fff94178284 NSApplicationMain + 1832
25 Demo 0x0000000100001cb2 main + 34
26 Demo 0x0000000100001c64 start + 52)

[_SwiftValue identifier]: unrecognized selector sent to instance 0x608000446b40

I'm using Swift3.0 on Xcode8 and get this error.

// MASPreferencesWindowController.m

- (NSArray *)toolbarItemIdentifiers
{
    NSMutableArray *identifiers = [NSMutableArray arrayWithCapacity:_viewControllers.count];
    for (id viewController in _viewControllers)
        if (viewController == [NSNull null])
            [identifiers addObject:NSToolbarFlexibleSpaceItemIdentifier];
        else
            [identifiers addObject:[viewController identifier]];  // <<= crash
    return identifiers;
}

I have a NSViewController setup like this.

class GeneralPreferencesViewController: NSViewController, NSWindowDelegate, MASPreferencesViewController {
    // MARK: - MASPreferencesViewController
    override var identifier: String? {
        get { return "general" }
        set { super.identifier = newValue }
    }
    var toolbarItemLabel: String? {
        return nil
    }
    var toolbarItemImage: NSImage? {
        return nil
    }
...

Any idea?

Integrated with Carthage.

XIB not included in podspecs

I have tried converting to using cocoapods instead, but the MASPreferencesWindow.xib is not in the pod.

Did you leave it out on purpose ?

Incorrect zoom button handling results in view positioning error

If one goes through a series of steps the view in the fixed-size preference pane is laid partially on top of the toolbar.

Steps:

  1. Click "Preferences" button
  2. Click "Advanced" tab
  3. Click Zoom (green) button
  4. Click "General" tab
  5. Click Zoom (green) button
  6. See the doom of everlasting NSView chaos (also known as the bug)

Link to screen recoding reproducing the above steps: http://cl.ly/FtxX
Link to picture showing aforementioned bug: http://cl.ly/FuZn

Getting error while setting up in Swift

I am getting this error while inheriting MASPreferencesViewController. Can you please provide some more guideline about integrating in swift project. Not getting much from swift edge case description.

import MASPreferences
public class PrefsController: MASPreferencesViewController {

}

Getting errors:

Type 'PrefsController' does not conform to protocol 'MASPreferencesViewController'
Type 'PrefsController' does not conform to protocol 'NSObjectProtocol'

And do i need to import anything in app-Bridging-Header.h file?

Podspec & Version Bump

Could you please run pod trunk push MASPreferences.podspec? You should run that after each version bump so that the new version can be automatically downloaded by users when they run pod update.

Speaking of which, could you please consider doing a version bump too? I am trying to use the 10.13 SDK for my app, which is incompatible with the latest release (1.2, or as far as Cocoapods is concerned, 1.1.4).

Add new version tag

The latest and only tag is for version 1.0, which is now 1 year old.

It would be interesting to tag a new version to include the recent bug fixes and updates. It will also make it possible to push the new version to @CocoaPods.

viewWillAppear called twice

In setSelectedViewController, it seems that viewWillAppear ends up getting called twice. It is called explicitly once, but calling setContentView on the window also seems to cause it to be called.

if ([controller respondsToSelector:@selector(viewWillAppear)])
    [controller viewWillAppear];

[self.window setContentView:controllerView];

Is the explicit call needed?

ViewControllers still alive after closing preferences

I can't figure this out, but it's probably easy. Sorry if that's the case. When I open the preferences window and then close it, the viewControllers are still alive. Is there a way to remove them?

The problem is that the controllers are saving data even though they are not visible.

Resizing Support for Auto Layout

When using Auto Layout, the autoresizing masks can't be set to indicate a fixed width or height.

jpvasquez@d1c9356 apparently fixes this by adding an optional property to the protocol. Please consider adding something similar.

Add tags?

Hi Vadim,

Would you consider adding tags to MASPreferences (and potentially your other projects)? On top of being useful in its own right, I would like to use those tags to add a spec file to CocoaPods (one of the tools for managing 3rd party dependencies in Xcode projects).

Best practices for setting first responder in preference view controllers?

Seems no matter what I do in my preference view controller, I can't control the first responder when switching views.

Right now, in my view controller's viewWillAppear, I have the following:

[[self.view window] makeFirstResponder:self.someUIElementProperty];

But it doesn't seem to take. Any suggestions?

EDIT Sometimes, it pays to read code. Setting initialKeyView on my preference view controller.

Conflict with NSViewController in macOS 10.13 / Swift 4

First of all thanks a lot for this project.

As stated in README, there is a workaround for implementing the property identifier in Swift:

When using Swift you need to override the identifier from MASPreferencesViewController the following to be compatible with the mutable identifier String? in NSViewController

However in macOS 10.13 SDK and Swift 4, the type of identifier from NSViewController has been changed from String? to NSUserInterfaceItemIdentifier?, which made the above trick no longer working.

[NSImage dissolveToPoint:fraction:] is deprecated in Mountain Lion

Some methods MASPreferences uses are deprecated in Mac OS X Mountain Lion:

*** WARNING: -[NSImage dissolveToPoint:fraction:] is deprecated in MacOSX 10.8 and later. Please use -[NSImage drawAtPoint:fromRect:operation:fraction:] instead.
*** WARNING: -[NSImage dissolveToPoint:fromRect:fraction:] is deprecated in MacOSX 10.8 and later. Please use -[NSImage drawAtPoint:fromRect:operation:fraction:] instead.

Getting exception when loading preferences screen

I am newbie using MASPreferences in Swift and Storyboard for design.

Following is my application code:
AppDelegate.swift

 @IBAction func openPreferences(sender: AnyObject) {
        preferencesWindowController().showWindow(sender)
    }

func preferencesWindowController() -> NSWindowController {
        if mPreferencesWindowController == nil {
            let accountViewController: NSViewController = AccountViewController()
            let advanceViewController: NSViewController = AdvanceViewController()
            let controllers : [AnyObject] = [accountViewController, advanceViewController]
            let title: String = NSLocalizedString("Preferences", comment: "Common title for Preferences window")
            self.mPreferencesWindowController = MASPreferencesWindowController(viewControllers: controllers, title: title)
        }
        return mPreferencesWindowController!
    }

AccountViewController.swift

class AccountViewController: NSViewController, MASPreferencesViewController {
    //Other codes
    override var identifier: String? { get {return "Account"} set { super.identifier = newValue} }

    var toolbarItemImage: NSImage! {
        return NSImage(named : "Account")!
    }

    var toolbarItemLabel: String {
        return "Account"
    }
}

Getting this exception:

2015-11-27 01:34:28.554 ottodj[36666:4245308] -[NSNib _initWithNibNamed:bundle:options:] could not load the nibName: ottodj.AccountViewController in bundle (null).
2015-11-27 01:34:28.556 ottodj[36666:4245308] (
    0   CoreFoundation                      0x00007fff968b7e32 __exceptionPreprocess + 178
    1   libobjc.A.dylib                     0x00007fff885864fa objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff9691e65d +[NSException raise:format:] + 205
    3   AppKit                              0x00007fff9382f70f -[NSNib _initWithNibNamed:bundle:options:] + 608
    4   AppKit                              0x00007fff9382f465 -[NSViewController _nibWithName:bundle:] + 127
    5   AppKit                              0x00007fff9382f0bf -[NSViewController loadView] + 129
    6   AppKit                              0x00007fff9379c662 -[NSViewController _loadViewIfRequired] + 75
    7   AppKit                              0x00007fff9379c5cd -[NSViewController view] + 30
    8   MASPreferences                      0x0000000100361c2e -[MASPreferencesWindowController setSelectedViewController:] + 862
    9   MASPreferences                      0x0000000100362b1f -[MASPreferencesWindowController toolbarItemDidClick:] + 127
    10  AppKit                              0x00007fff93a9947e -[NSToolbarButton sendAction:to:] + 75
    11  AppKit                              0x00007fff939c6e03 -[NSToolbarItemViewer mouseDown:] + 4996
    12  AppKit                              0x00007fff93f1a42d -[NSWindow _handleMouseDownEvent:isDelayedEvent:] + 6322
    13  AppKit                              0x00007fff93f1b411 -[NSWindow _reallySendEvent:isDelayedEvent:] + 212
    14  AppKit                              0x00007fff93960b8d -[NSWindow sendEvent:] + 517
    15  AppKit                              0x00007fff938e0b27 -[NSApplication sendEvent:] + 2540
    16  AppKit                              0x00007fff93747d9a -[NSApplication run] + 796
    17  AppKit                              0x00007fff93710fbe NSApplicationMain + 1176
    18  ottodj                              0x000000010006e307 main + 87
    19  libdyld.dylib                       0x00007fff92e375ad start + 1
    20  ???                                 0x0000000000000003 0x0 + 3
)

Can you please guide me if i am missing something.
Thanks in advance!

Cannot add an initialiser with no arguments in subclasses of MASPreferencesWindowController

As a convenience, I currently subclass MASPreferencesWindowController (from Swift, if it makes any difference), and initialise it with the various view controllers that I'd like to use in my preferences window. In MASPreferences 1.1.4, it would look something like this:

init() {
    super.init(viewControllers: [FirstPreferencesViewController(),
                                 SecondPreferencesViewController()],
               title: NSLocalizedString("Preferences", comment: "Preferences Title"))
}

However, since updating to MASPreferences 1.2.1, I've noticed that I can't use an initialiser without any arguments, as I'm told that I cannot override 'init()' which has been marked unavailable: Please use initWithViewControllers:title:. As a result, I'm having to declare my initialiser as init(_: ()), the closest I can get to no arguments.

It seems like this line in MASPreferencesWindowController.h:72 is the cause:

- (instancetype)init __attribute((unavailable("Please use initWithViewControllers:title:")));

While I appreciate that it's a good way of preventing usage of NSObject's default - init initialiser (accidental or otherwise), it's annoying that it also blocks subclasses from creating their own.

As I don't think is a particularly exotic use case, would it be possible to resolve this?

window controller shouldn't call super's awakeFromNib

I don't know if system classes do anything useful in awakeFromNib, but I always assumed this was a callback method that you're simply supposed to implement in your classes, but you don't need to (or shouldn't) call super in those methods. This does work on 10.6 (although I don't know if there's any point in doing that), but it fails on 10.5, so I get an exception while trying to show a window. I think this call to super can be safely removed.

Does not conform to MASPreferencesViewController

The snippet in the readme does not work

##Swift Edge case When using Swift you need to override the identifier from MASPreferencesViewController the following to be compatible with the mutable identifier String? in NSViewController

override var identifier: String? { get {return "general"} set { super.identifier = newValue} }

Platform: Xcode 8.3.3, macOS 10.12 SDK & target

Crashes Application

If you have the Sparkle framework, and add a custom object with the class SUUpdater to the view xib, the app will crash when on that view. Even without connecting anything.

ToolBar Buttons not visible when used as Sheet in Yosemite

Hi,

I am testing the latest version of MASPreferences in the current Yosemite Beta (GM candidate 1) and for some reason the ToolBar Buttons are not displayed when the preference window is displayed as Sheet.

You can simple reproduce the issue in the MASPreferences Demo:

  • go to (IBAction)openPreferences:(id)sender in DemoAppDelegate
  • Replace [self.preferencesWindowController showWindow:nil] with [self.window beginSheet:self.preferencesWindowController.window completionHandler:nil]

This will show the window as sheet but without the ToolBar Buttons. I am not sure if this a bug in Yosemite or in MASPreferences. Do you know this issue? Does anyone know how solve or bypass this problem?

Thanks!

Customising tabs

Hi, Vadim and others!

Is there an ideas way to change font size, icon size, active tab background and similar (what seem to be) basic properties? I explored all the component code but I can't figure it out.

screen shot 2017-05-18 at 15 43 11

It's probably trivial since there isn't anything on the web about but the thing is I've never opened Xcode until 10 days ago and I'm actually a designer - so please don't tell me to subclass something... :D

Thanks!

viewDidDisappear called twice

This is the same problem that was seen with viewWillAppear in #32

My app had some code that setup KVO in viewWillAppear and tore it down in viewWillDisapper. The first time it was called, removing the KVO observers worked fine. Then it was called a second time and my code wasn't handling this properly so it tried to remove the observers again which threw an exception.

Which BSD license?

I am using MASPreferences in a project and want to make sure that I am attributing the use of this project correctly.

According to the wikipedia entry, there are several versions of the BSD license. Can you advice me what version of the BSD license you intend to use and amend the LICENSE file with the full text?

Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.