Locator

Locator[{x,y}]

represents a locator object at position {x,y} in a graphic.

Locator[Dynamic[pos]]

takes the position to be the dynamically updated current value of pos, with this value being reset if the locator object is moved.

Locator[{x,y},obj]

displays obj as the locator object.

Locator[{x,y},None]

displays nothing visible as the locator object.

Details and Options

  • Locator[{x,y},Automatic] uses the default "crosshairs" appearance for the locator object.
  • Locator[Dynamic[{x,y}]] will reset the values of x and y when the locator object is moved; Locator[{x,y}] will not.
  • Locator[Dynamic[{x,y}],None] gives no directly visible indication of position, but can be used in conjunction with a construct such as Point[Dynamic[{x,y}]]. »
  • Locator objects that appear inside Deploy[expr] can still be manipulated interactively, just like, for example, Slider objects. »
  • If obj does not define its own absolute size, its size when used as a locator object can be specified using the ImageSize option of Locator.
  • The setting for ImageSize can be Tiny, Small, Medium, Large, or an explicit value in printer's points. »
  • The center of the locator object is taken to be the setting for the AlignmentPoint option of obj, or by default, the center of the bounding box for obj.
  • The following options can be given:
  • Appearance Automaticbasic appearance of the locator
    AutoAction Falsewhether to move automatically when the mouse is over the graphic
    Enabled Automaticwhether the locator is enabled, or grayed out
    ImageSize Automaticthe size of the displayed locator object
    LocatorRegion Automaticwhere the locator object should be allowed to go
  • Locator[] is equivalent to Locator[Scaled[{0.5,0.5}]]. »
  • Locator can be used to specify the control for a variable in Manipulate, to indicate that the value of the variable should be determined by the position of a locator. »

Examples

open allclose all

Basic Examples  (3)

Set up a locator that can move in a graphic:

Set up locator that defines the value of p:

Put a locator in a Manipulate:

Scope  (7)

Locator Content  (4)

Use an expression as a locator object:

Use a graphic as a locator object:

Invisible locator:

Zero-argument form for a locator:

Locator Control  (3)

Use Deploy to disable interactive graphics editing, but preserve locator interactivity:

The movement of locators can be constrained by Dynamic:

Use Scaled coordinates for the locator:

Options  (11)

Appearance  (1)

Specify the type of appearance:

AutoAction  (2)

By default, no locator values change until you drag the locator:

When AutoAction is set, the locator values change as the mouse moves over the locator:

Background  (2)

Change the background colors:

Change the background color dynamically:

Enabled  (2)

By default, Locator is enabled:

By setting Enabled->False, the locator is disabled but visible in its current state:

ImageSize  (2)

Use predefined locator sizes:

Or use any values:

LocatorRegion  (2)

By default, Locator is constrained within the PlotRange:

Use LocatorRegion->Full to access all of the graphics:

Applications  (2)

Dynamic tracking functions can be used to constrain locator movement:

A simple, interactive length and slope display:

Properties & Relations  (2)

Use Deploy to restrict graphics interactivity while keeping the locators active:

Use LocatorPane to use locators on complex objects:

Possible Issues  (1)

The position of a locator in graphics determines whether it is visible:

Neat Examples  (3)

Make the points follow the locator:

Transform the circle using a matrix defined by the coordinates of two locators:

Compute a Julia set for a mapping defined by a locator position:

Wolfram Research (2007), Locator, Wolfram Language function, https://reference.wolfram.com/language/ref/Locator.html.

Text

Wolfram Research (2007), Locator, Wolfram Language function, https://reference.wolfram.com/language/ref/Locator.html.

CMS

Wolfram Language. 2007. "Locator." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/Locator.html.

APA

Wolfram Language. (2007). Locator. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Locator.html

BibTeX

@misc{reference.wolfram_2023_locator, author="Wolfram Research", title="{Locator}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/Locator.html}", note=[Accessed: 19-March-2024 ]}

BibLaTeX

@online{reference.wolfram_2023_locator, organization={Wolfram Research}, title={Locator}, year={2007}, url={https://reference.wolfram.com/language/ref/Locator.html}, note=[Accessed: 19-March-2024 ]}