OutlineView | OutlineView for SwiftUI on macOS | Frontend Framework library

 by   Sameesunkaria Swift Version: 1.0.1 License: MIT

kandi X-RAY | OutlineView Summary

kandi X-RAY | OutlineView Summary

OutlineView is a Swift library typically used in User Interface, Frontend Framework, Xcode applications. OutlineView has no bugs, it has no vulnerabilities, it has a Permissive License and it has low support. You can download it from GitHub.

OutlineView is a SwiftUI view for macOS, which allows you to display hierarchical visual layouts (like directories and files) that can be expanded and collapsed. It provides a convenient wrapper around AppKit's NSOutlineView, similar to SwiftUI's OutlineGroup embedded in a List or a List with children. OutlineView provides it's own scroll view and doesn't have to be embedded in a List.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              OutlineView has a low active ecosystem.
              It has 7 star(s) with 0 fork(s). There are 1 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              OutlineView has no issues reported. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of OutlineView is 1.0.1

            kandi-Quality Quality

              OutlineView has no bugs reported.

            kandi-Security Security

              OutlineView has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.

            kandi-License License

              OutlineView is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              OutlineView releases are available to install and integrate.
              Installation instructions, examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of OutlineView
            Get all kandi verified functions for this library.

            OutlineView Key Features

            No Key Features are available at this moment for OutlineView.

            OutlineView Examples and Code Snippets

            No Code Snippets are available at this moment for OutlineView.

            Community Discussions

            QUESTION

            (Swift) Strange feedback when drag&drop NSOutlineview
            Asked 2021-Apr-10 at 21:31

            First of all, sorry for my English, I'll try my best to make it clear.(Edited with @Chip Jarred's suggestion,I've made some changes to simplify my question)

            What I managed to do is achieving NSOutlineview drag & drop method, using .gap style(I just want to use this style!):

            ...

            ANSWER

            Answered 2021-Apr-10 at 21:31

            After doing some research, I found multiple reports of a bug with NSTableView when using the .gap dragging style. It would seem that NSOutlineView is inheriting that bug. In any case, I found a work-around.

            The problem is that when you drag below the last top-level item, the item and childIndex passed to outlineView(_:acceptDrop:item:childIndex) are always nil and 0, which are exactly the same values you get when dragging to the top of list. The only way I could find to differentiate between the two cases was to use the draggingLocation from NSDraggingInfo to compare against the first item's cell frame, and use that to translate the index.

            Source https://stackoverflow.com/questions/67022140

            QUESTION

            How to print an NSOutlineView with NSVIew.printView
            Asked 2021-Feb-08 at 19:25

            I want to print an NSOutlineView. The view is a subview of a window on screen. I noticed the NSView api call printView. So I tried it in a simple minded fashion. In my AppDelegate I have a call:

            ...

            ANSWER

            Answered 2021-Feb-08 at 19:25

            Dark mode causes some issues with printing. The easiest workaround is to create a separate, programmatic view with forced light appearance, clone the required content and then print that view.

            view.appearance = NSAppearance(named: .aqua)

            Source https://stackoverflow.com/questions/66040103

            QUESTION

            Why View-Based NSOutlineView with autosaveExpandedItems true ignores expanded upon reloadData?
            Asked 2020-Aug-11 at 08:52

            I use a NSOutlineView that auto saves expanded state. If I manually reload data when dataSource updates, the func outlineView(_ outlineView: NSOutlineView, itemForPersistentObject object: Any) -> Any? datasource method is not called anymore and every cell collapses. Any idea why this might happen?

            Tried to reloadItem with nil send as param but still no good.

            I use this for persisting expanded rows:

            ...

            ANSWER

            Answered 2020-Aug-11 at 08:52

            IMHO autosaving is sort of half-baked feature and it doesn't work as expected. In other words, it's implemented in a way that it restores the state when your application launches (just once) and then you're on your own.

            Implement your own one utilizing outlineViewItemDidExpand(_:) & outlineViewItemDidCollapse(_:) (especially when we're reloading, ...).

            Couple of tricks you can use if you do not want to implement custom autosaving. But I wouldn't rely on them.

            First trick - tell the NSOutlineView to reload persistent state

            NSOutlineView inherits from the NSTableView and the autosaveName property documentation says:

            If you change the value of this property to a new name, the table reads in any saved information and sets the order and width of this table view’s columns to match. Setting the name to nil removes any previously stored state from the user defaults.

            What is inaccurate here - setting it to nil doesn't remove previously stored expanded items state for NSOutlineView. We can use it to force the NSOutlineView to reload expanded items state:

            Source https://stackoverflow.com/questions/63351982

            QUESTION

            Set control as first responder in other NSViewController
            Asked 2020-Aug-08 at 06:29

            I have a window with 3 NSViewControllers in a splitview - effectively a 3 level master detail. Inside each are, in order, an OutlineView, TableView and a details view (with lots of controls).

            When someone clicks on a row in the middle TableView, SelectionDidChange fires, and I call LoadData on the details view controller.

            I now want the details form to get focus - specifically an NSTextView on that form. So in LoadData, I call TextView.BecomeFirstResponder(), which returns true.

            But focus stays firmly on the TableView, and does not move to the details view. If I press a key, it goes to the TableView which uses it to select another row.

            Is there something simple I am missing? When one of the controls on the details view has focus, I can definitely move focus between controls, but not from another view controller.

            Thx. Paul,

            ...

            ANSWER

            Answered 2020-Aug-08 at 06:29

            Assuming your view controller view and TextView are already in window view hierarchy, do the following:

            Source https://stackoverflow.com/questions/63310572

            QUESTION

            Big Sur outline view expandable items broken
            Asked 2020-Jul-29 at 08:00

            I've started a new macOS project (currently on Big Sur beta 3), and the NSOutlineView nodes seem to be broken. Can't tell if this is me or the os.

            Here's a sample project that demonstrates the issue. And an image...

            As you can see, the cell is overlapping the expansion chevrons. Clicking on either chevron restores the first row to the proper layout, but not the second. Also, the autosave methods persistentObjectForItem and itemForPersistentObject are never called.

            The test project is super simple--all I did was add the SourceView component from the view library to the default app project and hook up the delegate/data source to the view controller. Also checked Autosave Expanded Items in IB and put a name in the Autosave field. Here's the entirety of the controller code:

            ...

            ANSWER

            Answered 2020-Jul-29 at 08:00
            Source list

            What is a source list? It's NSOutlineView (which is a subclass of NSTableView) with a special treatment. Finder screenshot:

            To create a source list, all you have to do is to set the selectionHighlightStyle property to .sourceList. The documentation says:

            The source list style of NSTableView. On 10.5, a light blue gradient is used to highlight selected rows.

            What it does exactly? Jump to Definition in Xcode and read comments (not included in the docs):

            The source list style of NSTableView. On 10.10 and higher, a blur selection is used to highlight rows. Prior to that, a light blue gradient was used. Note: Cells that have a drawsBackground property should have it set to NO. Otherwise, they will draw over the highlighting that NSTableView does. Setting this style will have the side effect of setting the background color to the "source list" background color. Additionally in NSOutlineView, the following properties are changed to get the standard "source list" look: indentationPerLevel, rowHeight and intercellSpacing. After calling setSelectionHighlightStyle: one can change any of the other properties as required. In 10.11, if the background color has been changed from the "source list" background color to something else, the table will no longer draw the selection as a source list blur style, and instead will do a normal blue highlight.

            Since you're on Big Sur, be aware that the SelectionHighlightStyle.sourceList is deprecated. One should use style & effectiveStyle.

            Sample project

            Xcode:

            • New project
              • macOS & App (Storyboard & AppKit App Delegate & Swift)
            • Main.storyboard
              • Add Source List control
                • Position & fix constraints
                • Set delegate & dataSource to ViewController
                • Enable Autosave Expanded Items
                • Set Autosave to whatever you want (I have FinderLikeSidebar there)
                  • Choose wisely because the expansion state is saved in the user defaults under the NSOutlineView Items FinderLikeSidebar key
                • Create @IBOutlet var outlineView: NSOutlineView!
              • Add another Text Table Cell View (no image)
                • Set identifier to GroupCell
            • ViewController.swift
              • Commented code below
            Screenshots

            As you can see, it's almost Finder like - 2nd level is still indented. The reason for this is that the Documents node is expandable (has children). I have them here to demonstrate autosaving.

            Just remove them if you'd like to move all 2nd level nodes to the left.

            ViewController.swift code

            There's not much to say about it except - read comments :)

            Source https://stackoverflow.com/questions/63094016

            QUESTION

            App Crashes Due to Binding to Table Cell View
            Asked 2020-Apr-10 at 09:57

            So I've created an NSOutlineView to display the file & directory list in a hierarchical way. I'm building a BitTorrent client (stating so the class names make sense).

            As you can see, this is pretty much how the outline view looks:

            The problem is associated with the Name column. In the name column, for each row, I have a checkbox and a text field side by side. This will help you get a clearer idea:

            Now, I use bindings to get the value for each textfield. However, since there are 2 views (checkbox and textfield) that needs to bound to the same NSTableCellView, I'm returning a struct, from the data source, containing 2 values: a string for the text field (which holds the file/directory name), and a boolean for enabling/disabling the checkbox.

            To handle the outline view (especially its data), I've set its class to TorrentContent, which is defined as below:

            ...

            ANSWER

            Answered 2020-Apr-10 at 09:57

            Cocoa Bindings uses Key Value Observing (KVO) and the observed object must be KVO compatible. See Using Key-Value Observing in Swift.

            You can only use key-value observing with classes that inherit from NSObject.

            Mark properties that you want to observe through key-value observing with both the @objc attribute and the dynamic modifier.

            Solution A: Return a KVO compatble object from outlineView(_:objectValueFor:byItem:)

            Solution B: Don't use Cocoa Bindings. Create a subclass of NSTableCellView and add a enabledCheckbox outlet. Set the values in outlineView(_:viewFor:item:).

            Source https://stackoverflow.com/questions/61135061

            QUESTION

            Swift: For Loop End Condition Evaluated Only Once?
            Asked 2020-Apr-10 at 07:40

            I am attempting to understand how Swift handles for-in loops.

            Overview: we are iterating over the rows of an NSOutlineView. If a condition is met, we expand the item, which obviously changes the overall row count of the outlineView.

            Pre-Condition: the OutlineView has 5 "root" items. Each of those has 5 child items.

            Example ...

            ANSWER

            Answered 2020-Apr-10 at 07:40

            0 ..< self.numberOfRows is a Range and in particular a Sequence. Iterating over a sequence is done by creating an iterator, and then calling its next() method until the iterator is exhausted, compare IteratorProtocol:

            Whenever you use a for-in loop with an array, set, or any other collection or sequence, you’re using that type’s iterator. Swift uses a sequence’s or collection’s iterator internally to enable the for-in loop language construct.

            So

            Source https://stackoverflow.com/questions/61135481

            QUESTION

            NSOutlineView expand childs
            Asked 2020-Mar-22 at 15:48

            I have an NSOutlineView where I'm trying to implement "search & replace" ability but the problem is that all nodes are not getting expanding.

            ...

            ANSWER

            Answered 2020-Mar-22 at 15:48

            Recursion, expand the parent before expanding the node:

            Source https://stackoverflow.com/questions/60775031

            QUESTION

            NSOutlineView unexpectedly found nil
            Asked 2020-Mar-01 at 17:48

            I am trying to make a file browser in my app that opens in a side panel (with a split view controller).

            The source is a URL brought by a prepareForSegue method in the previous viewController.

            Each time the vc loads i have the fatal error :

            Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value

            The compiler locates the error to where i declare :

            outlineView.delegate = self outlineView.dataSource = self

            I tried : 1. Undoing and redoing all my outlets connections, by code, by storyboard 2. Reconnecting delegates and datasource by code, by storyboard 3. I thought maybe something was wrong in my datasource method and i rewrote it 5 times 4. I tried to put my setDelegatesAndDatasource method in the viewDidAppear too, thinking it was a problem of view life cycle

            I can't understand what's going on. Thanks for your help.

            '''

            ...

            ANSWER

            Answered 2020-Mar-01 at 17:48

            The prepareForSegue code reveals the mistake:

            You are setting echo in prepareForSegue. This causes to call the property observer didSet. However at this moment the view is not loaded yet and force unwrapping the type crashes.

            The solution is to move the code in didSet into viewDidLoad and viewWillAppear and delete the property observer. Nevertheless I recommend to optional bind window

            Source https://stackoverflow.com/questions/60477210

            QUESTION

            Drag and Drop similar to Finder application NSOutlineView Cocoa Swift
            Asked 2020-Feb-20 at 22:55

            I want to implement drag and drop with NSOutlineView similar Mac Finder application. With my current implementation, drag and drop session validates drop to children of each parent. I don't want that. I only want to drop child from one parent to another parent. like moving file from one folder to another folder in Finder. How to do that? below is a sample code with my drag and drop code included.

            ...

            ANSWER

            Answered 2020-Feb-20 at 22:55

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install OutlineView

            You can install the OutlineView package using SwiftPM.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/Sameesunkaria/OutlineView.git

          • CLI

            gh repo clone Sameesunkaria/OutlineView

          • sshUrl

            git@github.com:Sameesunkaria/OutlineView.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link