NSScrollview / other suggestions ?

I’m happy with Massimo Valle’s OverlayScrollbars-master.

Please sign on to the following Feedback reports:

Native ScrollView:
<https://xojo.com/issue/16134>

Easier ability to create OS controls without screwing with the View Hierarchy
<https://xojo.com/issue/30708>

[quote=235923:@Rob Egal]@Sam Rowlands Is some situations we have chosen to use a HTMLViewer instead; for instance we found with Cardsmith that the templates was a lot quicker and easier if we simply used a HTMLView than trying to maintain an icon view ourselves.
so you mean you’ve worked with html code ?[/quote]
Yes, Cardsmith generates a HTML file when it needs to, then displays it or if no changes were made, it simply displays that HTML file and uses CancelLoad to capture when a user clicks on a icon.

@jim mckay perhaps @Joe Ranieri can confirm this, I thought any modification of the view hierarchy was potentially dangerous. Appending a subview via declares is still modifying the hierarchy, as it’s adding a subview without Xojo’s knowledge.

Kudos for the creative workaround

[quote=236004:@Sam Rowlands]Please sign on to the following Feedback reports:

Native ScrollView:
<https://xojo.com/issue/16134>
[/quote]
Hopefully with proper fallback to both Windows (no idea how native Window scollbars look like) and people with no trackpad.
(When my iMac’s trackpad is off, the TextArea scrollbar falls back to the old fashioned one. That looks really really bad.)

Crossing fingers that this will be added soon.

[quote=235941:@Rob Egal]That’s also good but requires an NSScroller class. What kind of NSScroller is it (overlay/standard)?
I didn’t manage to make an NSScroller being an overlay. :([/quote]

They are overlay scrollers (originally from Jim McKay) but with their own paint event so they don’t bounce, otherwise no visual difference from a real scrollview. Though now that Jim has posted a working scrollview example I guess that might be easier to implement.

[quote=236006:@Sam Rowlands]@jim mckay perhaps @Joe Ranieri can confirm this, I thought any modification of the view hierarchy was potentially dangerous. Appending a subview via declares is still modifying the hierarchy, as it’s adding a subview without Xojo’s knowledge.

[/quote]
The way I understood it, as long as the hierarchy that Xojo knows about is not altered, things should be safe. Adding a subview doesn’t alter the existing hierarchy, where inserting a view would (like a vibrancy visualEffectView requires to work). I could see where embedding a container after adding a subview to the window could potentially cause issues though…

AFAIK The only supported way is via plugin. Maybe I should have another go at the ole XCode template.

That’s what I used to think too but was told that while it is better to only add leaf views it still falls in the modify-view-hierarchy category.

@jim mckay I understood it to mean in line with what @Will Shank says, any modification to the view hierarchy runs the risk of breaking a Xojo made application, inserting or appending you’re still modifying the view hierarchy without Xojo’s knowledge.

Until we get a sanctioned method for creating OS controls, I’m just going to go with what we have.

I use Jims code for adding native scrollling in all my apps. Imo it is the only way to really make good looking (read: correct looking and native) OSX apps. It 100% boost sales your app because OSX users really EXPECT a native looking and behaving app. Well, at least all my apps benefits from it regarding sales figures.

So that brings us to Sams feedback cases. They are very important to be implemented imo

There is no real problem in inserting a view in the view hierarchy. There are just a few Xojo RectControl properties which you might not be able to use anymore in the Xojo control which was pushed down in the hierarchy (you would have to recalculate the stuff yourself): The position (Left, Top, etc.), locks (LockLeft, etc.), TabIndex, PanelIndex, and Parent come to my mind. I’ve used the inserted NSScrollView since Cocoa was in beta and never had any troubles.

signed mate.

[quote=236004:@Sam Rowlands]Please sign on to the following Feedback reports:

Native ScrollView:
<https://xojo.com/issue/16134>

Easier ability to create OS controls without screwing with the View Hierarchy
<https://xojo.com/issue/30708>[/quote]

signed!

[quote=236046:@Christoph De Vocht]I use Jims code for adding native scrollling in all my apps. Imo it is the only way to really make good looking (read: correct looking and native) OSX apps. It 100% boost sales your app because OSX users really EXPECT a native looking and behaving app. Well, at least all my apps benefits from it regarding sales figures.

So that brings us to Sams feedback cases. They are very important to be implemented imo[/quote]

That’s one of the most valuable feedback (xojo devs should read it). I couldn’t have it put better.

[quote=235967:@jim mckay]You can use a containercontrol to clip a canvas or container embedded in the parent containercontrol. Add an NSScrollView on top to handle the scrolling. The best way is to set the flipped property and handle the NSViewBoundsDidChangeNotification.

Here’s a working example (64bit works too)

It avoids messing with the view hierarchy by adding the scrollview as a subview of the existing view and locking the autoresizingmask to the parent container’s bounds.[/quote]

Big kudos for you for bringing in the example. I am still studying it. Too bad I wasn’t able to code
it myself. :frowning:

Just one comment:
Setup the lookup table before adding the subview as this will trigger boundschanged event.
The lookup table = nil and it will crash (just tested)

True.That’s, what I’ve learned while I’ve spent my time in coding the NSScollView but to no avail and the reasons for starting this discussion. I wasn’t able to “control” the created scrollview.

Almost the same approach as I did but I couldn’t get the left/top,x/y and other stuff to work as it needs to advanced obj-c stuff which I’m not so good in.

So thats why the scrollbars don’t automagically appear when resizing back the view.

I’ve made the original example project a bit more readable, added some nil checks
and a scrollToTop, scrollToBottom and scrollTo but left the original comments.
https://www.dropbox.com/s/ulsosfe77eqp6n1/NSScrollView_updated.xojo_binary_project?dl=0

Edit:
smaller update to above:

I have updated my current app using NSScollView example code by Jim. I am so excited.:slight_smile: :slight_smile: and it works like a charm !!!


I can only encourage all Xojo devs to use the NSScrollView class above or at least leave feedback to the Xojo Team to have them working on an official built-in version or make it simpler to modiy existing controls like Sam suggested:

[quote]Sam Rowlands Please sign on to the following Feedback reports:
Native ScrollView:
Feedback Case #16134
Easier ability to create OS controls without screwing with the View Hierarchy
Feedback Case #30708[/quote]

I’ve been experimenting with trying to add the scrollview programmatically but failed hard, anyone else?

Show the code/project.