Editable Nstextview from Interface Builder

Setting editable on a NSTextField doesn't have any effect

This was because by default when you bind the value of an NSTextField in Interface Builder it ticks the box Conditionally Sets Editable meaning that the value the text field is bound to sets the editable property of the text field.

Unticking this box made my original code work.

can't edit NSTextField in sheet at runtime

The view does not absolutely have to have a title bar.

See
Why NSWindow without styleMask:NSTitledWindowMask can not be keyWindow?

Which states: If you want a titleless window to be able to become a key window, you need to create a subclass of NSWindow and override -canBecomeKeyWindow as follows:

- (BOOL)canBecomeKeyWindow {
return YES;
}

This worked for me.

NSBorderlessWindowMask Subview NSTextfield not keybard editable Swift

I found an awesome workaround for this problem:
basically setup at beginning the NSWindow mask as NSTitledWindowMask, when application is loaded, remove set up the new mask NSBorderlessWindowMask

   func applicationWillFinishLaunching(notification: NSNotification) {
self.window?.titleVisibility = NSWindowTitleVisibility.Hidden
self.window?.styleMask = NSTitledWindowMask // adds title bar
}

func applicationDidFinishLaunching(aNotification: NSNotification) {

self.window?.makeKeyWindow()
self.window?.becomeKeyWindow()
self.window.setIsVisible(true)
self.window?.styleMask = NSBorderlessWindowMask // removes title bar
}


Related Topics



Leave a reply



Submit