FloatingContent Object

A FloatingContent object represents a single piece of content that floats alongside the normal text stream. Examples include floating images (wrap text around image), floating text boxes, and shapes.

Existing FloatingContent objects can be obtained using commands like:

Document.allFloatingContents

Selection.floatingContents

FloatingContent - General Properties

.displaySize v2.0

Returns a Size object for the current display size (in points) of this content on the page, taking into account scaling and cropping. This size does not include padding.

.anchorText v2.0

Returns the Text object to which this floating content is anchored, or the @undefined value if it is not applied in a document. Read-only.

Note: the returned text object follows reference semantics and holds the entire text area where the floating content is anchored (eg: the whole document body).

.anchorTextRange v2.0

Returns the Range object representing the specific paragraph within the anchorText object to which this content is currently anchored. Returns the @undefined value if this content is not applied in a document. Read-only.

.anchorOffset v2.0

Returns a Size object specifying where this content is positioned (in points) relative to its anchor. The width and height of this offset may be negative.

.enclosingGroup v2.0

If this content is inside a floating group (or canvas), returns the enclosing FloatingContent object. If this content is not inside a group, returns the @undefined value. Read-only.

FloatingContent - General Commands

.addToText text, range v2.1

Adds a copy of the content to the given Text object, which must allow floating content (eg: table cells cannot anchor floating content). The added content is anchored to the paragraph containing the given Range object, which must be in-bounds or an error is displayed.

Returns the copied FloatingContent object that was added, or the @undefined value on failure.

.removeFromDocument v2.0

Removes this content from the document/text it is currently applied to. If this content is inside a group/canvas, removes it from that group.

FloatingContent - Content Specific Properties and Commands

.isImage v2.0

Returns @true if the content is a floating image, otherwise @false. Read-only.

.image v2.0

Returns the Image object displayed by this floating content. If this content is not an image, returns the @undefined value. Read-only.

.setImage newImage, [adjustSize] v2.0

Changes this content to display the given image, which must be either an Image object or another FloatingContent object that represents an image. This command has no effect if this content is not already an image. 

If adjustSize is true, this content’s size is automatically adjusted to take on the size of the given image; otherwise the size is left as-is. If the argument is not provided, the default is to adjust the size automatically.

.isTextBox v2.0

Returns @true if the content is a floating text box or callout, otherwise @false. Read-only.

.text v2.0

Returns the Text object holding the textual content of the text box or callout. If this content is not a text box, returns the @undefined value. Read-only.

Note: the returned text object follows reference semantics, eg: changes to it will change the contents of the text box itself.

.isShape v2.0

Returns @true if the content is a floating shape, otherwise @false. Shapes include geometric figures like circles, squares, stars, as well as block arrows, but not lines (or lines with arrowheads). Read-only.

.shapeName v2.0

Returns the name of the shape, eg: "circle", "rect", "block arrow left", etc. This name does not follow any particular naming convention, but it will not change between releases of Nisus Writer. If this content is not a shape, returns the @undefined value. Read-only.

.isLine v2.0

Returns @true if the content is a floating line (with or without arrowheads), otherwise @false. Read-only.

.isGroup v2.0

Returns @true if the content is a group (or canvas) containing other floating contents, otherwise @false. Read-only.

.groupedContents v2.0

Returns an array of all FloatingContent objects contained inside the group. If this content is not a group, returns the @undefined value.

.shadingAttributes v2.1

Returns a ShadingAttributes object describing the appearance of the shape’s internal fill. The returned object follows value semantics, ie: changes to it will not automatically update the original floating content.

.strokeAttributes v2.1

Returns a LineAttributes object describing the appearance of the shape’s external edges. The returned object follows value semantics, ie: changes to it will not automatically update the original floating content.

.shadow v3.2

Returns the Shadow object that is drawn for the shape, or the undefined value if none. Changes to the returned shadow will not automatically update the shape, you must set the shape’s shadow property. See the example in the Shadow object reference.


Previous Chapter
CrossReference Object
<<  index  >>
 
Next Chapter
Image Object