Post

Replies

Boosts

Views

Activity

Reply to NSButton doesn't work anymore
My problem is still presentI precise that it is an existing projectwhen I run it, I have the following warnings;2019-12-13 14:06:48.087149+0100 adminSQL[5941:111502] Metal API Validation Enabled2019-12-13 14:06:48.114296+0100 adminSQL[5941:111963] flock failed to lock maps file: errno = 352019-12-13 14:06:48.114753+0100 adminSQL[5941:111963] flock failed to lock maps file: errno = 35Also, my controller is not a NSViewController, but an NSWindowControllerimport Cocoa class test: NSWindowController { override open var windowNibName: NSNib.Name? { let els = className.components(separatedBy: ".") if els.count > 1 { return els[1] } else { return els[0] } } override func windowDidLoad() { super.windowDidLoad() // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file. } @IBAction func Tester(_ sender: NSButton) { Swift.print("test activé") } }
Dec ’19
Reply to NSButton doesn't work anymore
Sorry, I made a mistake in my previous postit is truly a NSWindowControllerfirst the code:/ test.swift // adminSQL // // Created by Patrice Rapaport on 13/12/2019. // Copyright © 2019 Patrice Rapaport. All rights reserved. // import Cocoa class test: NSWindowController { override open var windowNibName: NSNib.Name? { let els = className.components(separatedBy: ".") if els.count > 1 { return els[1] } else { return els[0] } } override func windowDidLoad() { super.windowDidLoad() } @IBAction func Tester(_ sender: Any) { Swift.print("test activé") } }the name of my Swift file is test.swift and the name of the xib file is test.xibthe Class of File Owner in the IB interface is testThe delegate of the window is File's OwnerIn the xib file, I add a NSButton, I maintain CTRL down and I link it to the func "Tester"when I CTRL-Click the button in the B Interface, I see: action ... File Owner Tester:I made a github (I'm not an expert at this). adminSQL is a complete App, but in aPPDelegate I wrote:func applicationDidFinishLaunching(_ aNotification: Notification) { test().showWindow(self) return;so it ony access test file.The link to the git directory is :https://github.com/patricerapaport/adminSQL
Dec ’19
Reply to NSButton doesn't work anymore
If you mean my Email adress, it is patrice @ rapaport.frOr do you mean something else?To test, I've made a new project from scratch: h ttps: //github.com/patricerapaport/TestPushButtonit calls a NSViewController and when I click the push button, the action is performedNow there is a menu "actions" with two submenus: "Tester" and "Cliquer"The submenu "Tester" calls a NSWindowController and when I click the push button, nothing occursThe submenu "Cliquer" calls also a NSWindowController but the button is subclasse as CButtonhere the code:import Cocoa @IBDesignable class CButton: NSButton { var _controller: NSWindowController! var _target: Selector! @IBInspectable var controller: NSWindowController? { get { return _controller } set { _controller = newValue } } @IBInspectable override var target: AnyObject? { get { return _target as AnyObject?} set { _target = newValue as? Selector } } override func mouseDown(with event: NSEvent) { if action != nil { self.controller?.perform(self.target as? Selector, with: self) } } } class cliquerWindow: NSWindowController { @IBOutlet weak var btCliquer: CButton! override open var windowNibName: NSNib.Name? { let els = className.components(separatedBy: ".") if els.count > 1 { return els[1] } else { return els[0] } } override func windowDidLoad() { super.windowDidLoad() btCliquer.controller = self btCliquer.target = #selector(cliquer(_:)) as AnyObject } @IBAction @objc func cliquer(_ sender: Any) { Swift.print("CButton cicked") } }this work's.
Dec ’19
Reply to NSButton doesn't work anymore
I made the code of my NSWindowController simplier:import Cocoa @IBDesignable class CButton: NSButton { var _controller: NSWindowController! @IBInspectable var controller: NSWindowController? { get { return _controller } set { _controller = newValue } } override func mouseDown(with event: NSEvent) { if action != nil { self.window?.windowController?.perform(self.action, with: self) } else { super.mouseDown(with: event) } } } class cliquerWindow: NSWindowController { var num: Int = 1 @IBOutlet weak var btCliquer: CButton! override open var windowNibName: NSNib.Name? { let els = className.components(separatedBy: ".") if els.count > 1 { return els[1] } else { return els[0] } } override func windowDidLoad() { super.windowDidLoad() btCliquer.controller = self } @IBAction @objc func cliquer(_ sender: Any) { Swift.print("CButton clicked \(num)") num += 1 } }it work's well but as you can see, the var controller of the class CButton doesn't do anythingtry to comment the line #37 of this code, and it will not workhttps://github.com/patricerapaport/TestPushbuttonSimplified
Dec ’19
Reply to NSButton doesn't work anymore
Je ne suis pas certain que vous allez voir les messages qui étaient en train d'etre modérés, mais j'ai développé un petit projet partant de rien que vous pouvez trouver sur github: github/patricerapaport/TestPushbutonLa première vue- est une NSViewController (dans le Main.Storyboard) et le bouton qu'elle contient fonctionne correctementLa seconde vue, TesterWindow, que vous pouvez accéder avec le menu Actions/Tester est une NSWindowController, et le bouton ne déclenche pas l'action à laquelle il est reliéLa troisième vue, CliquerWindow, que vous pouvez accéder avec le menu Actions/cliquer est également une NSWindowController dans laquelle j'ai subclassé le bouton pour le faire réagir à MouseDown. Cela fonctionne correctement et en voici le code:import Cocoa @IBDesignable class CButton: NSButton { var _controller: NSWindowController! @IBInspectable var controller: NSWindowController? { get { return _controller } set { _controller = newValue } } override func mouseDown(with event: NSEvent) { if action != nil { self.window?.windowController?.perform(self.action, with: self) } else { super.mouseDown(with: event) } } } class cliquerWindow: NSWindowController { var num: Int = 1 @IBOutlet weak var btCliquer: CButton! override open var windowNibName: NSNib.Name? { let els = className.components(separatedBy: ".") if els.count > 1 { return els[1] } else { return els[0] } } override func windowDidLoad() { super.windowDidLoad() btCliquer.controller = self } @IBAction @objc func cliquer(_ sender: Any) { Swift.print("CButton clicked \(num)") num += 1 } }Vous remarquerez que la variable controller de CButton n'est pâs utilisée. Donc on devrait pouvoir commenter la ligne 37. Siu vous le faites, le bouton ne réagira plus au click.
Dec ’19
Reply to NSButton doesn't work anymore
Sorry to bother youo with this, but the main ViewController was there only to demonstrate that in a NSViewController the IBAction is calledThis is not the case for an NSWindowController, as demonstrated in TesterWindowI have a solution in the controller CliquerWindow, but is it normal to have to subclass the NSButton to make it fuctionnal?
Dec ’19
Reply to Swift UI and choice in a NavigationView
I'm not sure I understand your answerI have this structure:struct IvritMenu: Identifiable { let id: Int let text: String let destination: some View }On line 4 Xcode whow an error: Property declares an opaque return type, but has no initializer expression from which to infer an underlying typeIs it impossible to declare a variable as a view?
Dec ’19
Reply to Swift UI and choice in a NavigationView
So if I have this code;import SwiftUIstruct IvritMenu: Identifiable { let id: Int let text: String var destination: AnyView } struct MenuGeneral: View { var menu = [ IvritMenu(id:1, text: "Adjectifs", destination: AnyView(Adjectifs())), IvritMenu(id:2, text: "Adverbes", destination: AnyView(Adverbes())) ] var body: some View { NavigationView { List(menu) { choix in NavigationLink(destination: choix.destination) { Text(choix.text) } } .navigationBarTitle("Ivrit") } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { MenuGeneral() } }converning lines 9 and 10 does it means that the view Adjectifs and Adverbes are always created, or are they created only when I click on one of the links?
Dec ’19
Reply to NSWiewController
You are right, I chosse the firstbecause one thing I didn't told is that my application is document based so I can have multiple splitview and multiple toolbars.That"s why I was looking for the ancestorThank's
Jan ’20