Create a list with headers using SwiftUI and macOS - list

I like to build an old styled macOS app, not an iOS app! Therefore I need a list with a light grey background header row with the titles of the column.
Usualy the user can resize each column by dragging the end of the header column around. But how can I set it with SwiftUI?
I read a lot about iOS and manually setting some text (titles/headers) above. But the intention is to use a build-in functionality, that this title belongs to a column and when changing the width of the title, the column is also changed. Also a double click will sort the entire list accordingly to the clicked column up or down. The width of the columns will also automatically fit the content.
Where is the property to set all these features?

SwiftUI lists can have only one column. Xcode 13 adds a Table control for Mac apps. The Table control supports multiple columns, but it requires macOS 12.
To support earlier macOS versions, you can wrap AppKit views, such as NSTableView, in SwiftUI by creating a struct that conforms to NSViewRepresentable. Wrapping NSTableView should give you the Mac table view behavior you want.
SwiftUI does support Mac lists having the sidebar list style. Use SidebarListStyle as the list's style.
.listStyle(SidebarListStyle())

Related

Dropdown List in Catalyst

I am trying to add a dropdown list in my SwiftUI catalyst app. from what I read you have to use the picker, but it does not let you use the popupbuttonpicker style on iOS. so how can I achieve a Mac style dropdown list in catalyst? I assume I have to basically roll my own out using views and popups?
Make sure you set your app setting to "Optimize interface for Mac"

Can Power BI custom visuals accept keyboard focus?

I am trying to create a custom slicer that supports keyboard navigation.
I have come across the supportsKeyboardFocus property in capabilities.json, and I see that this changes the visual HTML element to look like the built in slicer which does support keyboard navigation (removes aria-hidden="true" and adds keyboard-shortcuts="ctrl-ArrowRight scoped") but am still unable to get keyboard focus inside a simple custom visual. Are there any working examples of a custom visual that supports keyboard navigation?
There was a regression in custom visuals' keyboard focus support, it has been fixed a few months ago.
In order to enable keyboard focus and navigation, the visual should:
Set supportsKeyboardFocus: true in capabilities.json file.
Contain focusable elements1
Also note that in a Power BI report, visuals behave as context groups, so navigation between visuals is achieved using Tab, and navigation into a visual's context is done by ctrl+rightArrow (or cmd+rightArrow for Apple).
1: While there are many DOM elements which are focusable by default (e.g. buttons, text input etc.), many custom visuals are based purely on SVG graphics, so they can end up with no focusable elements. For the most basic tab based navigation, adding tabindex=0 to an element is enough. For good accessibility, depending on the visual, it's typically required to add keyboard support for selection and multi-selection, and better navigation (e.g. arrow based grid navigation, or some reasonable grouping of elements etc.)

UITextView text color when Editable attribute is disabled

I migrated an app to Swift 3. I've managed all the changes but I'm struggling with this particular problem. I have some UITextView in a UITable with are populated with some email address.
In my old Swift 2 version, these views where not editable, with the link data detection enabled. However, after the migration, with the "not editable" version the text inside the text views is displayed in white color. If if re-activeate the "Editable" option, the view content turns again to black.
What is the dataDetectorType that you are using? If you are using link, you can either change the tintColor, or you can use linkTextAttributes to manipulate the style to your liking

Disable only specific list items in a win32 ListView

I am using win32, c++.
I have a ListView & i want to disable (grey out) only some of the items from the list.
Is that possible or only whole ListView can be greyed out?
The ListView control does not have a concept of disabled items. You can simulate that appearance using custom drawing support. This Sample demonstrates how to change the text and background color of items within the list view.
You would need to go further and provide some means of determining when a disabled item is selected within the view (as the selection will continue to work).
The Windows List View Common Control does not have a disabled state for Items. If you want to do that, you will have to implement it yourself.
This is a not-trivial exercise. It's not hard to change the visible appearance using customer draw, but handling hit-testing and selection would be quite complex.

How do you get a list picker like the kind shown in the alarm clock?

How do you create the big, scrolling list picker, like the kind that is created for datePicker and timePicker which is used on the WP7 default alarm clock? The remaining list pickers don't have quite the same effect. I would be using the list pickers only to choose integer values.
Thanks
The DatePicker and TimePicker are controls that are provided by the Silverlight Toolkit for WP7. What they actually do is present the selection in one control in your page, then navigate to a separate page that allows you to actually select a new date/time. In these separate pages they use a collection of LoopingSelector controls (one per item) that enable the user to select the parts of the date/time.
If you want to display a similar picker but for numeric values, then you need to implement the same infrstructure but using a single LoopingSelector and you need to provide the correct data source (that implements the ILoopingSelectorDataSource interface) that specifies the values for your control.
There is a great series of 3 posts on the LoopingSelector on WindowsPhoneGeek.com