Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Fetching latest commit…

Cannot retrieve the latest commit at this time

..
Failed to load latest commit information.
.gitignore
AppDelegate.cs
ColorRect.cs
EdgeMarkerBottom.tiff
EdgeMarkerLeft.tiff
EdgeMarkerRight.tiff
EdgeMarkerTop.tiff
Info.plist
Main.cs
MainMenu.xib
MainMenu.xib.designer.cs
MyWindow.cs
MyWindow.xib
MyWindow.xib.designer.cs
MyWindowController.cs
NestleView.cs
README.md
RectsView.cs
Rulers.csproj
Rulers.sln

README.md

NSRulerView Client Example

This project demonstrates many of the interactions between an NSRulerView and its client view. It should give you an idea how to go about this when creating a view subclass that really does something.

The principal class, RectsView, displays colored rectangles that the user can select and drag around. The RectsView puts markers in the horizontal and vertical rulers showing the placement of the rectangle; manipulating these markers changes the size of the selected rectangle. Removing a marker deletes the selected rectangle, and clicking in the ruler area creates a new rectangle. The user can also lock a rectangle down, so that the markers can't be moved.

RectsView.m defines a lot of methods, but these are the ones primarily related to working with NSRulerViews:

METHOD ACTION ====== ======

rulerView:shouldMoveMarker: Denies move if no selection or if selection is locked.

rulerView:willMoveMarker: Limits minimum rectangle size and toLocation: updates display; try changing this to snap markers to whole units.

rulerView:didMoveMarker: Refreshes ruler display.

rulerView:shouldRemoveMarker: Denies remove of no selection or if selection is locked.

rulerView:didRemoveMarker: Deletes the selected rectangle and refreshes the display.

rulerView:shouldAddMarker: Returns YES, always allowing new rectangles to be added.

rulerView:willAddMarker: Returns the proposed location unchanged; atLocation: try changing this to snap markers to whole units.

rulerView:didAddMarker: Creates a new rectangle.

rulerView:handleMouseDown: Adds a new marker to be tracked.

rulerView:willSetClientView: Does nothing.

Something went wrong with that request. Please try again.