Skip to content

NSScrollViewCanvas

Inherits DesktopTextInputCanvas

Description

A subclass of the DesktopTextInputCanvas that provides native scrollbars on macOS.

Properties

Name Type Read-Only
HasHorizontalScrollbar Boolean
HasVerticalScrollbar Boolean
LookupTable Dictionary
NSDocumentView Ptr
NSNotificationCenter Ptr
NSScrollerStyle NSScrollerStyles
NSScrollView Ptr
NSScrollViewCustom Ptr
ScrollX_ Integer
ScrollY_ Integer

Methods

Name Parameters Returns
NSScrollerStyleChanged obj As Ptr, sel As Ptr, notification As Ptr
NSScrollViewMagnifyWithEvent obj As Ptr, sel As Ptr, evt As Ptr
NSViewBoundsDidChange obj As Ptr, sel As Ptr, notification As Ptr
NSViewIsFlipped obj As Ptr, sel As Ptr Boolean
PerformBoundsChanged
PerformScaling scaleOffset As Double
PerformScrollerStyleChanged
ScrollToPoint x As Double, y As Double
SetDocumentSize width As CGFloat, height As CGFloat

Events

Name Parameters Returns
Closing
NSScrollerStyleChanged style As NSScrollerStyles
NSScrollViewBoundsChanged bounds As CGRect
NSScrollViewMagnify scaleOffset As Double
Opening

Constants

Name Type
kAppKit String
kFoundation String
kObjC String

kAppKit As String The AppKit library name for declares.


kFoundation As String The Foundation library name for declares.


kObjC As String The objective-C dynamic library name for declares.


Enumerations

NSScrollerStyles

Constants to specify the scroller style.

Legacy: Specifies legacy-style scrollers as prior to macOS 10.7.

Overlay: Specifies overlay-style scrollers in macOS 10.7 and later.

Name
Legacy
Overlay

Property Descriptions

HasHorizontalScrollbar As Boolean

True if the canvas should have a horizontal scrollbar.


HasVerticalScrollbar As Boolean

True if the canvas should have a horizontal scrollbar.


LookupTable As Dictionary

This property is shared.

A dictionary mapping Xojo objects with Objective-C classes. Key = object Ptr, Value = WeakRef.


NSDocumentView As Ptr

The reference to the DocumentView subclass.


NSNotificationCenter As Ptr

A pointer to NSNotificationCenter.


NSScrollerStyle As NSScrollerStyles

This property is shared.

The preferred scroller style.


NSScrollView As Ptr

This is the reference to the NSScrollView subclass instance.


NSScrollViewCustom As Ptr

Internal use. A pointer to our custom NSScrollView.


ScrollX_ As Integer

The most recent X scroll position.


ScrollY_ As Integer

The most recent Y scroll position.


Method Descriptions

NSScrollerStyleChanged(obj As Ptr, sel As Ptr, notification As Ptr) This method is shared.

Internal use. The scroller style changed.


NSScrollViewMagnifyWithEvent(obj As Ptr, sel As Ptr, evt As Ptr) This method is shared.

Internal use. This is where we handle the magnify gesture.


NSViewBoundsDidChange(obj As Ptr, sel As Ptr, notification As Ptr) This method is shared.

Internal use. The view bounds has changed.


NSViewIsFlipped(obj As Ptr, sel As Ptr) As Boolean This method is shared.

Internal override method. Always returns True.


PerformBoundsChanged()

Internal use. called from the shared bounds changed method, after looking up the instance in LookupTable.


PerformScaling(scaleOffset As Double)

Internal use. called from the shared magnify method, after looking up the instance in LookupTable.


PerformScrollerStyleChanged()

Internal use. called from the shared scroller style changed method, after looking up the instance in LookupTable.


ScrollToPoint(x As Double, y As Double)

Scrolls the canvas to a point (x, y).


SetDocumentSize(width As CGFloat, height As CGFloat)

Sets the document size to width x height.


Event Descriptions

Closing() The canvas is closing.


NSScrollerStyleChanged(style As NSScrollerStyles) The scroller style has changed.


NSScrollViewBoundsChanged(bounds As CGRect) The scroll view bounds has changed.


NSScrollViewMagnify(scaleOffset As Double) The amount by which the content is currently scaled.


Opening() The canvas is opening.


Acknowledgements

This class is a minimally modified version of a class provided by Martin Trippensee. He can be found on the Xojo forums.