qnx.fuse.ui.text.TextBase

TextBase

Properties | Methods | Events


Packageqnx.fuse.ui.text
Classpublic class TextBase
InheritanceTextBase Inheritance UIComponent Inheritance flash.display.MovieClip
Subclasses EditableText, Label

The TextBase class provides base functionality for rendering and selecting text.

Class information:
BlackBerry 10 Version:   10.0.0

See also

EditableText



Public Properties

 PropertyDefined By
 InheritedcontextActions : Vector.<ActionSet>
Gets or Sets a Vector of ActionSet objects.
UIComponent
 InheritedcontextMultiSelectText : String
Gets or Sets a String to be displayed when showing the Multi Select Context Menu.
UIComponent
 InheritedcurrentTheme : String
[read-only] Returns the current theme this component is styled with.
UIComponent
 InheritedexplicitHeight : Number
[read-only] Returns the explicit height (actual height, in pixels) of the UI component.
UIComponent
 InheritedexplicitWidth : Number
[read-only] Returns the explicit width (actual width, in pixels) of the UI component.
UIComponent
  format : TextFormat
Gets or sets the format of the text.
TextBase
 Inheritedid : String
The id is a name for the component that can be used in CSS using the # selector.
UIComponent
 InheritedincludeInLayout : Boolean
Specifies whether or not the component should be included in its parent container's layout.
UIComponent
  layoutComplete : Boolean
[read-only] Returns true if all of the text has been renderered and laid out.
TextBase
 InheritedlayoutData : Object
Gets or sets the layoutData.
UIComponent
  length : int
[read-only] Returns the length of the text that is being rendered.
TextBase
 Inheritedlocale : String
Gets or sets the current locale of the component.
UIComponent
  maxLines : int
Gets or sets the maximum number of lines to be measured by a layout.
TextBase
 InheritedminHeight : Number
Gets or sets the minimum preferred height of the control.
UIComponent
  minLines : int
Gets or sets the minimum number of lines to be measured by a layout.
TextBase
 InheritedminWidth : Number
Gets or sets the minimum preferred width of the control.
UIComponent
  selectable : Boolean
Gets or sets a value that determines whether text can be selected.
TextBase
  selected : Boolean
[read-only] Returns true if the component has a text selection and false if it does not.
TextBase
  selectionActiveIndex : int
[read-only] Returns the zero-based index of the first character in the selection.
TextBase
  selectionAnchorIndex : int
[read-only] Returns the zero-based index of the last character in the selection.
TextBase
 InheritedstyleChildren : Boolean
Allows you to style the children of this component with CSS.
UIComponent
  text : String
Gets or sets the text of the component.
TextBase
  textHeight : Number
[read-only] Gets the current height of the text.
TextBase
  textWidth : Number
[read-only] Gets the current width of the text.
TextBase
  virtualLayout : Boolean
Gets or sets the virtualLayout property.
TextBase

Protected Properties

 PropertyDefined By
 InheritedaccessibilityImplimentationClass : Class
UIComponent
  cssID : String
[override] [read-only] Returns the CSS ID of the component.
TextBase
  enableEmoticons : Boolean
Gets or sets a value that enables or disables emoticons from being displayed.
TextBase
 InheritedexplicitLocale : Boolean
Set to true when the locale property has been set externally.
UIComponent
 InheritedinternalID : String
The Component's Id used for styling.
UIComponent
 InheritedlongPressEnabled : Boolean
Specifies whether the UIComponent can detect a long press.
UIComponent
  userSelection : Boolean
Returns true if the user initiated the selection.
TextBase

Public Methods

 MethodDefined By
  
Do not instantiate this class.
TextBase
 Inherited
Cancels a long press from occuring on the component.
UIComponent
 Inherited
childChanged(resizedChild:DisplayObject = null):Boolean
Notifies the UIComponent that one or more of its children has changed in a manner that may affect this object's layout.
UIComponent
 Inherited
destroy():void
Call this method when you want to have your object collected by the garbage collector.
UIComponent
 Inherited
Returns the CSS selector for the object, composing it from its position in the display hierarchy and an optional ID selector.
UIComponent
 Inherited
Returns the size options for the given control.
UIComponent
  
getTextLineAt(index:int):TextLine
Gets a TextLine instance at a specific index.
TextBase
 Inherited
Calling this method results in a call to the components validateDisplayList() method before the display list is rendered.
UIComponent
 Inherited
Calling this method results in a call to the components validateProperties() method before the display list is rendered.
UIComponent
 Inherited
measure(availableWidth:Number, availableHeight:Number):LayoutMeasurement
This method calls doMeasure() in order to calculate the preferred size of the control.
UIComponent
  
registerEmoticons(emoticons:Vector.<Emoticon>):void
Registers a set of emoticons with the text component.
TextBase
  
scrollInView(position:int, immediate:Boolean = false):void
Scrolls the position into view.
TextBase
 Inherited
setActualSize(w:Number, h:Number):void
Sets the width and height of the object without setting the explicitWidth and explicitHeight.
UIComponent
 Inherited
setLayoutBounds(bounds:Rectangle):void
Sets the receiver's size and location to the rectangular area specified by the arguments.
UIComponent
 Inherited
setPosition(x:Number, y:Number):void
Sets the x and y position of the component.
UIComponent
  
setSelection(anchorIndex:int, activeIndex:int):void
Sets the range of selected text.
TextBase
 Inherited
updateDefaultLocale(updateChildren:Boolean = true):void
Updates the locale property to be the same as the locale of the device.
UIComponent
 Inherited
Lets a component that contains text know that it should update its font formats as the font settings have changed.
UIComponent
 Inherited
Validates the display list of the component by calling the updateDisplayList().
UIComponent
 Inherited
Validates the component immediately by calling validateProperties(), validateSizes(), and validateDisplayList() if necessary.
UIComponent
 Inherited
Validates the properties of the component by calling the commitProperties() method.
UIComponent

Protected Methods

 MethodDefined By
  
addTextLine(line:TextLine):Boolean
Adds a created text line to the display list and the textLines property.
TextBase
 Inherited
allowShowContextMenu(target:IEventDispatcher):Boolean
When the user presses on the component this method is called with the object that dispatched the event.
UIComponent
 Inherited
Process properties of the component.
UIComponent
 Inherited
Process the state of the component.
UIComponent
 Inherited
Style the component after the style has changed.
UIComponent
  
composeLines(width:Number, height:Number):Boolean
Creates all TextLine instances given the specified width and height.
TextBase
  
createTextLines(width:Number, height:Number):void
Renders the text at the specified width and height.
TextBase
  
cursor2linePos(cursor:Cursor, consumer:Function):void
Given a specified cursor, this method calls the consumer parameter with TextLine and the x position of the cursor.
TextBase
  
cursor2word(cursor:Cursor, consumer:Function):void
Based on a cursor, call the consumer with the logical start and end of the word in the text.
TextBase
 Inherited
doMeasure(availableWidth:Number, availableHeight:Number):LayoutMeasurement
Performs a measurement on the control, and returns a LayoutMeasurement instance containing the available width and height within the layout.
UIComponent
  
event2cursor(stageX:Number, stageY:Number, rail:TextLine):Cursor
Gets a cursor given x and y cordinates of the component, expressed in the stage corrdinate system.
TextBase
  
event2word(stageX:Number, stageY:Number, consumer:Function):void
Based on x and y positions in the stage corrdinate system, call the consumer with the logical start and end of the word in the text.
TextBase
 Inherited
excemptFromCSSStyling(target:*, property:String = null):void
Exempts a property on an object from being styled by CSS.
UIComponent
 Inherited
flushCache():void
Invoked as part of parentLayoutChanged.
UIComponent
 Inherited
getStyleApplier():Function
A style applier is a method that gets called every time a property from the stylesheet should be applied to the component.
UIComponent
  
Gets the text alignment for laying out the text.
TextBase
  
Gets the text to be rendered by the component.
TextBase
 Inherited
onAdded():void
Called when the instance is added to the stage.
UIComponent
 Inherited
Is called when a user is no longer long pressing on the component.
UIComponent
 Inherited
Is called when a user long presses on the component.
UIComponent
 Inherited
onRemoved():void
Called when the instance is removed from the stage.
UIComponent
 Inherited
Invalidates the parent's size and display list if includeInLayout property is set to true.
UIComponent
  
position2cursor(position:int):Cursor
Return a Cursor object given the specified position in the text.
TextBase
  
positionLine(line:TextLine, atIndex:int = -1):void
Positions an single line.
TextBase
  
positionLines(width:Number, height:Number, lines:Vector.<TextLine>):Point
Positions the specified lines.
TextBase
  
recycleLine(line:TextLine):void
Recycles the specified line and adds it to the cache to be re-used.
TextBase
 Inherited
Calling this function will refresh the ContextMenu with whatever actions were set by contextActions.
UIComponent
  
Removes the current TextLine instances from the display list.
TextBase
  
Called when the text is moving during a scroll.
TextBase
 Inherited
Shows the context menu if there are contextActions associated with the control.
UIComponent
 Inherited
styleState():void
Style the component after state has changed.
UIComponent
  
Called when text lines have been created and positioned.
TextBase
 Inherited
updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
Sets the size and position of the children of the component.
UIComponent

Events

 Event Summary Defined By
 InheritedDispatched when an action in the Context Menu is selected.UIComponent
 InheritedDispatched when the Context Menu has closed to the DISMISSED state.UIComponent
 InheritedDispatched when the ContextMenu is closing to the DISMISSED state.UIComponent
 InheritedDispatched when the Context Menu has opened to the PEEK or EXPANDED state.UIComponent
 InheritedDispatched when the ContextMenu is opening from the DISMISSED state.UIComponent
  Dispatched when the textWidth or textHeight properties change.TextBase
 InheritedDispatched when the CrossCut multiselect has been canceled.UIComponent
  Dispatched when there has been a change in the selection of the text.TextBase
  Dispatched when a user has clicked on a link in the text.TextBase

Property Detail

cssID


cssID:String  [read-only]
[override]

Returns the CSS ID of the component. The CSS ID is used for identifying the type of component in CSS.

The default value is TextBase.


Implementation

protected function get cssID():String

enableEmoticons


enableEmoticons:Boolean

Gets or sets a value that enables or disables emoticons from being displayed.

This is set by the registerEmoticons() method. Passing in a Vector with a length bigger then 0 will set this property to true. Otherwise it is set to false.


Implementation

protected function get enableEmoticons():Boolean
protected function set enableEmoticons(value:Boolean):void

See also

registerEmoticons()

format


format:TextFormat

Gets or sets the format of the text.


Implementation

public function get format():TextFormat
public function set format(value:TextFormat):void

See also

TextFormat

layoutComplete


layoutComplete:Boolean  [read-only]

Returns true if all of the text has been renderered and laid out.


Implementation

public function get layoutComplete():Boolean

See also

virtualLayout

length


length:int  [read-only]

Returns the length of the text that is being rendered.

This may be different than calling text.length(); Emoticons in the text count as 1 character.


Implementation

public function get length():int

maxLines


maxLines:int

Gets or sets the maximum number of lines to be measured by a layout.

The text component will render additional lines, if necessary, and will be clipped from view. Setting this value to 0 causes all lines to be measured.

The default value is 0.


Implementation

public function get maxLines():int
public function set maxLines(value:int):void

minLines


minLines:int

Gets or sets the minimum number of lines to be measured by a layout.

If the full text results in less lines than the minimum number of lines, then the size of the minimum number of lines will be returned when measuring the text. Setting this value less then 1 will have no effect and will be constrained to 1.

The default value is 1.


Implementation

public function get minLines():int
public function set minLines(value:int):void

selectable


selectable:Boolean

Gets or sets a value that determines whether text can be selected.

The default value is true.


Implementation

public function get selectable():Boolean
public function set selectable(value:Boolean):void

selected


selected:Boolean  [read-only]

Returns true if the component has a text selection and false if it does not.


Implementation

public function get selected():Boolean

selectionActiveIndex


selectionActiveIndex:int  [read-only]

Returns the zero-based index of the first character in the selection.


Implementation

public function get selectionActiveIndex():int

See also

selectionAnchorIndex

selectionAnchorIndex


selectionAnchorIndex:int  [read-only]

Returns the zero-based index of the last character in the selection.


Implementation

public function get selectionAnchorIndex():int

See also

selectionActiveIndex

text


text:String

Gets or sets the text of the component.


Implementation

public function get text():String
public function set text(value:String):void

textHeight


textHeight:Number  [read-only]

Gets the current height of the text.

In order for this value to return something other then NaN, the component must render text. Because text rendering is deferred by a frame, the size of the text may not be immediately available after setting the text property. You can force a render by calling validateNow() once the component has been added to the display list. Alternatively, you can listen for the TextEvent.LAYOUT_ESTIMATE_CHANGE event, which is dispatched when either the textWidth or textHeight property has changed.

NOTE: If the layoutComplete property is false the value returned is a best estimate or the size of the currently rendered text.

If text is truncated, the size of the rendered truncated text is returned and not the size of the entire block of text.

The default value is NaN.


Implementation

public function get textHeight():Number

textWidth


textWidth:Number  [read-only]

Gets the current width of the text.

In order for this value to return something other then NaN, the component must render text. Because text rendering is deferred by a frame, the size of the text may not be immediately available after setting the text property. You can force a render by calling validateNow() once the component has been added to the display list. Alternatively, you can listen for the TextEvent.LAYOUT_ESTIMATE_CHANGE event, which is dispatched when either the textWidth or textHeight property has changed.

NOTE: If the layoutComplete property is false the value returned is a best estimate or the size of the currently rendered text.

A line of text is only rendererd to the width of the component. Due to this the value returned will never be bigger then the width of the component.

The default value is NaN.


Implementation

public function get textWidth():Number

userSelection


userSelection:Boolean

Returns true if the user initiated the selection. Returns false if the selection was set from a call to setSelection()


Implementation

protected function get userSelection():Boolean
protected function set userSelection(value:Boolean):void

See also

setSelection()

virtualLayout


virtualLayout:Boolean

Gets or sets the virtualLayout property.

When set to true, only visible text is rendered initially. If there is more text beyond the bounds of the view port, new lines will be added as the text is scrolled into view. When set to false, all lines of text lines will be created.

When placed in a Container and the virtualLayout property is true, it is important set sizing options of your layout to SizeOptions.RESIZE_VERTICAL. This will ensure that the component is sized correctly allowing for only visible lines to be rendered. It is also important to ensure the container is not scrollable. Scrolling the text should be left up to the text control, which allows it to add new lines as necessary.

The default value is false.


Implementation

public function get virtualLayout():Boolean
public function set virtualLayout(value:Boolean):void

See also

layoutComplete


Example
The following code shows how to use this property with a Container
var container:Container = new Container();
var layout:GridLayout = new GridLayout();
layout.numColumns = 1;
layout.setOptions(SizeOptions.RESIZE_VERTICAL);
layout.setTopLevelAlign(Align.FILL, Align.FILL );
container.layout = layout;
var label:Label = new Label();
label.truncationMode = TextTruncationMode.CLIP;
label.maxLines = 0;
label.virtualLayout = true;
label.text = "Add some really long text here.";
container.addChild( label );
addChild( container );
container.width = stage.stageWidth;
container.height = stage.stageHeight;
         

Constructor Detail

TextBase()


public function TextBase()

Do not instantiate this class.

Method Detail

addTextLine()


protected function addTextLine(line:TextLine):Boolean

Adds a created text line to the display list and the textLines property.

This method calls the positionLine() method, which positions the line. Once the line is positioned, this method is also responsible for updating the actualTextWidth and actualTextHeight properties.

Parameters

line:TextLine — The text line to add.

Returns

Boolean — Returns true if more lines should be created.

composeLines()


protected function composeLines(width:Number, height:Number):Boolean

Creates all TextLine instances given the specified width and height.

This method creates the necessary text lines and calls addTextLine() for each created line. Overriding this method and failing to call this method will cause undesired behavior.

Parameters

width:Number — The width that composed lines should fit in to.
height:Number — The height that composed lines should fit in to.

Returns

Boolean — Returns true if all of the text lines were created.

createTextLines()


protected final function createTextLines(width:Number, height:Number):void

Renders the text at the specified width and height.

Parameters

width:Number — The available width to render text into.
height:Number — The available height to render text into.

cursor2linePos()


protected final function cursor2linePos(cursor:Cursor, consumer:Function):void

Given a specified cursor, this method calls the consumer parameter with TextLine and the x position of the cursor. The consumer function should be the following: function( line:TextLine, x:Number ):void

Parameters

cursor:Cursor — The cursor whose position you wish to know.
consumer:Function — A consumer function with the signature function( line:TextLine, x:Number ):void which will be called with the text line and x position of the Cursor.

cursor2word()


protected final function cursor2word(cursor:Cursor, consumer:Function):void

Based on a cursor, call the consumer with the logical start and end of the word in the text. The consumer should look like the following: function( wordStart:int, wordEnd:int ):void

Parameters

cursor:Cursor — The cursor whose surrounding word you wish to know.
consumer:Function — A consumer function with the signature function( wordStart:int, wordEnd:int ):void which will be called with the word start and end indexes.

event2cursor()


protected final function event2cursor(stageX:Number, stageY:Number, rail:TextLine):Cursor

Gets a cursor given x and y cordinates of the component, expressed in the stage corrdinate system. If rail is non-null, it is a TextLine that acts as a rail. If the point is in the rail or in the top half of the following line, then it is "moved" in the rail before being interpreted.

Parameters

stageX:Number — The x coordinate of where the Cursor should be created, in stage coordinates.
stageY:Number — The Y coordinate of where the Cursor should be created, in stage coordinates.
rail:TextLine — A rail along which to place the Cursor.

Returns

Cursor — Returns a new Cursor around the specified x and y position.

event2word()


protected final function event2word(stageX:Number, stageY:Number, consumer:Function):void

Based on x and y positions in the stage corrdinate system, call the consumer with the logical start and end of the word in the text. The consumer should look like the following: function ( wordStart:int, wordEnd:int ):void

Parameters

stageX:Number — X coordinate inside the component, expressed in stage coordinate space.
stageY:Number — Y coordinate inside the component, expressed in stage coordinate space.
consumer:Function — A consumer function with the signature function( wordStart:int, wordEnd:int ):void which will be called with the word start and end indexes.

getTextAlignment()


protected function getTextAlignment():String

Gets the text alignment for laying out the text.

When the format.align property is set to "start", "left" is returned when the text is rendered left to right, and "right" when the text is rendered right to left.

When the format.align property is set to "end", "left" is returned when the text is rendered right to left, and "right" when the text is rendered left to right.

Returns

String — The alignment of the text.

See also

TextAlign

getTextLineAt()


public function getTextLineAt(index:int):TextLine

Gets a TextLine instance at a specific index.

Parameters

index:int — The index of the TextLine to return.

Returns

TextLine — The TextLine at the specified index.

getTextToDisplay()


protected function getTextToDisplay():String

Gets the text to be rendered by the component. Component developers can override this method in order to modify the text before rendering it.

Returns

String — The text to be rendered by the component.

position2cursor()


protected final function position2cursor(position:int):Cursor

Return a Cursor object given the specified position in the text.

Parameters

position:int — The position in the text to place the cursor.

Returns

Cursor — A new Cursor at the specified position in the text.

positionLine()


protected function positionLine(line:TextLine, atIndex:int = -1):void

Positions an single line.

Parameters

line:TextLine — The text line to position.
atIndex:int (default = -1) — The index to position the line at. By default this is set to -1. In this case the line will be positioned from the previous line.

positionLines()


protected function positionLines(width:Number, height:Number, lines:Vector.<TextLine>):Point

Positions the specified lines.

This method calls the positionLine method to position the lines. If you wish adjust how lines are positioned, it is recommend to override that method instead.

Parameters

width:Number — The width to position the text lines within.
height:Number — The height to position the text lines within.
lines:Vector.<TextLine> — A Vector of TextLines that represent all of the created lines that are to be laid out.

Returns

Point — A Point where the x value is the width of the text and the y value is the height of the text.

recycleLine()


protected function recycleLine(line:TextLine):void

Recycles the specified line and adds it to the cache to be re-used. This method is called from the removeLines() method when lines are removed.

Parameters

line:TextLine — The TextLine to be recycled.

registerEmoticons()


public function registerEmoticons(emoticons:Vector.<Emoticon>):void

Registers a set of emoticons with the text component.

If there are already emoticons set, then they are replaced with the specified set. If the emoticons parameter is set to null, it will remove all previously registered emoticons.

By default no emoticons are registered with the component.

Parameters

emoticons:Vector.<Emoticon>

See also

Emoticon
enableEmoticons

removeLines()


protected function removeLines():void

Removes the current TextLine instances from the display list.

scrollInView()


public function scrollInView(position:int, immediate:Boolean = false):void

Scrolls the position into view.

Parameters

position:int — The index in the text to scroll into view.
immediate:Boolean (default = false) — When set to true the position is immediately scrolled into view. By default this argument is set to false and will scroll the text into view when the component has been validated.

scrollUpdate()


protected function scrollUpdate():void

Called when the text is moving during a scroll.

setSelection()


public function setSelection(anchorIndex:int, activeIndex:int):void

Sets the range of selected text.

You must set the selectable and enabled to true in order to create a selection.

Parameters

anchorIndex:int — The first character position of the selection.
activeIndex:int — The last character position of the seletion.


Throws

ArgumentError — When the anchorIndex value is bigger then the activeIndex.

See also

selectable

textRenderComplete()


protected function textRenderComplete():void

Called when text lines have been created and positioned.

Event Detail

layoutEstimateChange


Event Object Type: qnx.fuse.ui.events.TextEvent
TextEvent.type property = qnx.fuse.ui.events.TextEvent.LAYOUT_ESTIMATE_CHANGE

Dispatched when the textWidth or textHeight properties change. It is important to note that these properties are not guaranteed to be 100% accurate at all times. When listening for this event you can check if the layoutComplete property is true, which indicates that all of text has been laid out and the values for textWidth or textHeight are 100% accurate.

This event is fired when the dimensions of the text have changed.

The TextEvent.LAYOUT_ESTIMATE_CHANGE constant defines the value of the type property of the event object for an layoutEstimateChange event.

The properties of the event object have the following values:

PropertyValue
bubblesfalse
cancelablefalse
currentTargetThe object that is actively processing the Event object with an event listener.
typeTextEvent.LAYOUT_ESTIMATE_CHANGE

See also

textWidth
textHeight
layoutComplete

selectionChanged


Event Object Type: qnx.fuse.ui.events.TextEvent
TextEvent.type property = qnx.fuse.ui.events.TextEvent.SELECTION_CHANGED

Dispatched when there has been a change in the selection of the text. If the selected property is true there is a selection.

This event is fired when a selection is changed or cleared.

The TextEvent.SELECTION_CHANGED constant defines the value of the type property of the event object for an selectionChanged event.

The properties of the event object have the following values:

PropertyValue
bubblesfalse
cancelablefalse
currentTargetThe object that is actively processing the Event object with an event listener.
typeTextEvent.SELECTION_CHANGED

See also

selected

textLink


Event Object Type: qnx.fuse.ui.events.TextEvent
TextEvent.type property = qnx.fuse.ui.events.TextEvent.LINK

Dispatched when a user has clicked on a link in the text. Links can be set using Label.htmlText and using the anchor tag.

This event is fired when a user presses on a link in the text.

The TextEvent.LINK constant defines the value of the type property of the event object for an textLink event.

The properties of the event object have the following values:

PropertyValue
bubblesfalse
cancelablefalse
currentTargetThe object that is actively processing the Event object with an event listener.
typeTextEvent.LINK
urlThe url of the link that was clicked in the text.

See also

Label.htmlText





comments powered by Disqus