Instance Method

initWithRulerView:markerLocation:image:imageOrigin:

Initializes a newly allocated ruler marker, associating it with (but not adding it to) a specified ruler view and assigning the attributes provided.

Declaration

- (instancetype)initWithRulerView:(NSRulerView *)ruler markerLocation:(CGFloat)location image:(NSImage *)image imageOrigin:(NSPoint)imageOrigin;

Parameters

aRulerView

The ruler view with which to associate the ruler marker. This method raises an NSInvalidArgumentException if aRulerView is nil.

location

The x or y position of the marker in the client view’s coordinate system, depending on whether the ruler view is horizontal or vertical.

anImage

The image displayed at the marker location. This method raises an NSInvalidArgumentException if anImage is nil.

imageOrigin

The point within the image positioned at the marker location, expressed in pixels relative to the lower-left corner of the image.

Return Value

An initialized ruler marker object.

Discussion

The image used to draw the marker must be appropriate for the orientation of the ruler. Markers may need to look different on a horizontal ruler than on a vertical ruler, and the ruler view neither scales nor rotates the images.

To add the new ruler marker to aRulerView, use either of NSRulerView’s addMarker: or trackMarker:withMouseEvent: methods. addMarker: immediately puts the marker on the ruler, while trackMarker:withMouseEvent: allows the client view to intercede in the addition and placement of the marker.

A new ruler marker can be moved on its ruler view, but not removed. Use movable and removable to change these attributes. The new ruler marker also has no represented object; use representedObject to set one.

This method is the designated initializer for the NSRulerMarker class.

See Also