NSScrollview / other suggestions ?

Hello everyone,

Xojo is lacking of a good scroll view and overlay scrollers unfortunately and so I am wondering what options a developer has?
Is it possible to implement an NSScollview that works at all? I have tried it but am not able to handle it correctly
in containers and have it moving around like a canvas.

The Xojo build-in scollers sometimes just don’t fit in a modern UI so I cannot use it but I haven seen application made with
Xojo using mac osx native scrollers so there must be a solution out there. Even the Xojo feedback app use it but there no code
available? Is this a secret ?

See MacOSLib.

Xojo Feedback app uses HTMLViewer as a kind of workaround.

of course without using plugins :slight_smile:

how is it supposed to work ?

What for ? Is there an NSScrollView implemented ? :slight_smile:

Yes.

That would be a question for the author of the Feedback app :wink:

The Dashboard view and each case view in the Feedback app are just HTML pages displayed locally in HTMLViewer – that’s why there is a native OS X scrollbar present and native inertial scrolling supported. The Messages pane at the bottom of the Xojo IDE window is created in the same way.

I don’t see a NSScrollView class. What do I need to look for ?

Jason King has a NSScrollView in his ‘add ons to macoslib v3’ at the Here link
https://forum.xojo.com/conversation/post/141437

Not sure if there’s newer versions.

Getting a scrollview in Xojo can be done, but to get it work correctly is a lot of work.

I’ll probably get into trouble for this; but you can hack a TextArea to insert a canvas or container control into it (instead of the TextView), just make sure that you replace the original document before the window is closed or it crashes.

It breaks the Xojo view hierarchy, so it may or may not work in a future version of Xojo and it may lead to crashes.

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.

[quote=235907:@Sam Rowlands]Getting a scrollview in Xojo can be done, but to get it work correctly is a lot of work.

I’ll probably get into trouble for this; but you can hack a TextArea to insert a canvas or container control into it (instead of the TextView), just make sure that you replace the original document before the window is closed or it crashes.

It breaks the Xojo view hierarchy, so it may or may not work in a future version of Xojo and it may lead to crashes.[/quote]

I read about in the feedback app I think but you’re not getting into trouble. Xojo should offer us good alternatives.
It feels sometime that I use built-in controls from 2007 or so.

so you mean you’ve worked with html code ?

[quote=235900:@Grzegorz Pawlik]That would be a question for the author of the Feedback app :wink:

The Dashboard view and each case view in the Feedback app are just HTML pages displayed locally in HTMLViewer – that’s why there is a native OS X scrollbar present and native inertial scrolling supported. The Messages pane at the bottom of the Xojo IDE window is created in the same way.[/quote]

Sounds reasonable. I actually suspected a sort of hack too. :slight_smile:

I use a containercontrol with a pagepanel and NSScrollers and then embed another containercontrol in that. Haven’t noticed any issues at all. Maybe i’m lucky :wink:

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. :frowning:

[quote=235907:@Sam Rowlands]I’ll probably get into trouble for this; but you can hack a TextArea to insert a canvas or container control into it (instead of the TextView), just make sure that you replace the original document before the window is closed or it crashes.
[/quote]
I tried that. Also tried to somehow use the TextArea scrollposition and run it next/under a listbox, container, canvas etc. It works but it’s a lot of hassle.
I remember I stopped trying when I saw that the Textarea scrollbar on an Mac without a trackpad switched back to the old style. Still wonder how to do it though.

Mac OSLib NSTableView example uses NSScrollView. The calls are in there. Simply search for NSScrollView in the project.

If that was for me, unless for the pleasure of discovery/hack, I would simply buy dtPlugin. Jean-Paul probably spent many good hours getting it to work transparently.

You could try to insert a NSScrollView into the view hierarchy (see my post in this thread: Canvas.MouseWheel Boundaries Control).

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.