PXTextField Class Reference
| Inherits from | PXInteractiveObject : PXDisplayObject : PXEventDispatcher : NSObject |
| Declared in | PXTextField.h PXTextField.m |
Overview
A display object which represents a line of text.
Example: The following code creates a text field with the Helvetica font, that can only accept letters ‘,’ and ‘!’ with size of 30.0f.
[PXTextureFont registerSystemFontWithFont:@"Helvetica"
name:@"fontName"
fontOptions:[PXFontOptions fontOptionsWithSize:30.0f
characterSets:PXFontCharacterSet_AllLetters
specialCharacters:@",!"]];
PXTextField *textField = [[PXTextField alloc] initWithFont:@"fontName"];
textField.text = @"Hi!";
Tasks
-
textThe text of the text field.
property -
fontThe registered name of the font.
property -
fontSizeThe size of the text.
property -
alignThe alignment of the text.
property -
alignHorizontalThe horizontal alignment of the text. Ranges between 0.0f and 1.0f.
property -
alignVerticalThe vertical alignment of the text. Ranges between 0.0f and 1.0f.
property -
letterSpacingThe extra space between each letter.
property -
textColorThe color of the text.
property -
backgroundColorThe background color of the text field.
property -
backgroundAlphaThe background alpha of the text field.
property -
backgroundIf
propertyYESit displays the background of the text field. -
borderColorThe border color of the text field.
property -
borderAlphaThe border alpha of the text field.
property -
borderIf
propertyYESit displays the border of the text field. -
smoothingIf the text should be smoothed when transformed.
property -
kerningIf
propertyYESand the font has kerning values stored, then your text will be kerned. -
– initWithFont:Creates a new PXTextField with a registered font.
-
+ textFieldCreates a PXTextField using the default font (
PXTextFieldDefaultFont). No text will be displayed until you set the text property of the PXTextField just created. If no texts exists, then the this object will appear to have 0 size. -
+ textFieldWithFont:Creates a PXTextField using the registered font if it exists, or the default font (
PXTextFieldDefaultFont). No text will be displayed until you set the text property of the PXTextField just created. If no texts exists, then the this object will appear to have 0 size. -
+ textFieldWithFont:text:Creates a PXTextField with a registered font.
Properties
align
The alignment of the text.
@property (nonatomic) PXTextFieldAlign alignDiscussion
Default: PXTextFieldAlign_TopLeft
Declared In
PXTextField.halignHorizontal
The horizontal alignment of the text. Ranges between 0.0f and 1.0f.
@property (nonatomic) float alignHorizontalDiscussion
Default: 0.0f
Declared In
PXTextField.halignVertical
The vertical alignment of the text. Ranges between 0.0f and 1.0f.
@property (nonatomic) float alignVerticalDiscussion
Default: 0.0f
Declared In
PXTextField.hbackground
If YES it displays the background of the text field.
@property (nonatomic) BOOL backgroundDiscussion
Default: NO
Declared In
PXTextField.hbackgroundAlpha
The background alpha of the text field.
@property (nonatomic) float backgroundAlphaDiscussion
Default: 1.0f
Declared In
PXTextField.hbackgroundColor
The background color of the text field.
@property (nonatomic) unsigned backgroundColorDiscussion
Default: 0xFFFFFF – white
Declared In
PXTextField.hborder
If YES it displays the border of the text field.
@property (nonatomic) BOOL borderDiscussion
Default: NO
Declared In
PXTextField.hborderAlpha
The border alpha of the text field.
@property (nonatomic) float borderAlphaDiscussion
Default: 1.0f
Declared In
PXTextField.hborderColor
The border color of the text field.
@property (nonatomic) unsigned borderColorDiscussion
Default: 0x000000 – black
Declared In
PXTextField.hfont
The registered name of the font.
@property (nonatomic, copy) NSString *fontDiscussion
Default: PXTextFieldDefaultFont
Declared In
PXTextField.hfontSize
The size of the text.
@property (nonatomic) float fontSizeDiscussion
Default: 12.0f
Declared In
PXTextField.hkerning
If YES and the font has kerning values stored, then your text
will be kerned.
@property (nonatomic) BOOL kerningDiscussion
Default: YES
Declared In
PXTextField.hletterSpacing
The extra space between each letter.
@property (nonatomic) float letterSpacingDiscussion
Default: 0.0f
Declared In
PXTextField.hsmoothing
If the text should be smoothed when transformed.
@property (nonatomic) BOOL smoothingDiscussion
Because smoothing is a relatively expensive operation, it’s recommended to only turn it on when the text field is being transformed (such as during an animation).
Default: NO
Declared In
PXTextField.hClass Methods
textField
Creates a PXTextField using the default font
(PXTextFieldDefaultFont). No text will be displayed until you
set the text property of the PXTextField just created. If no texts exists,
then the this object will appear to have 0 size.
+ (PXTextField *)textFieldDiscussion
Example:
PXTextField *textField = [PXTextField textField];
See Also
Declared In
PXTextField.mtextFieldWithFont:
Creates a PXTextField using the registered font if it exists, or the default
font (PXTextFieldDefaultFont). No text will be displayed until
you set the text property of the PXTextField just created. If no texts
exists, then the this object will appear to have 0 size.
+ (PXTextField *)textFieldWithFont:(NSString *)_fontNameParameters
- fontName
The name of the registered font. If the font does not exist or was not registered then the default (
PXTextFieldDefaultFont) is used instead.Example:
PXTextField *textField = [PXTextField textField];
See Also
Declared In
PXTextField.mtextFieldWithFont:text:
Creates a PXTextField with a registered font.
+ (PXTextField *)textFieldWithFont:(NSString *)_fontName text:(NSString *)_textParameters
- text
The text for the text field.
Example:
[PXTextureFont registerSystemFontWithFont:@"Helvetica" name:@"fontName" fontOptions:[PXFontOptions fontOptionsWithSize:30.0f characterSets:PXFontCharacterSet_AllLetters specialCharacters:@",!"]]; PXTextField *textField = [PXTextField textFieldWithFont:@"fontName" text:@"Hi"];
- fontName
The name of the registered font. If the font does not exist or was not registered then the default (
PXTextFieldDefaultFont) is used instead.
See Also
Declared In
PXTextField.mInstance Methods
initWithFont:
Creates a new PXTextField with a registered font.
- (id)initWithFont:(NSString *)_fontNameParameters
- fontName
The name of the registered font. If the font does not exist or was not registered then the default (
PXTextFieldDefaultFont) is used instead.Example:
[PXTextureFont registerSystemFontWithFont:@"Helvetica" name:@"fontName" fontOptions:[PXFontOptions fontOptionsWithSize:30.0f characterSets:PXFontCharacterSet_AllLetters specialCharacters:@",!"]]; PXTextField *textField = [[PXTextField alloc] initWithFont:@"fontName"]; textField.text = @"Hi!";
See Also
Declared In
PXTextField.m