Urho3D
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions
Urho3D::LineEdit Class Reference

Single-line text editor UI element. More...

#include <LineEdit.h>

Inheritance diagram for Urho3D::LineEdit:
Urho3D::BorderImage Urho3D::UIElement Urho3D::Serializable Urho3D::Object Urho3D::RefCounted

List of all members.

Public Member Functions

 LineEdit (Context *context)
 Construct.
virtual ~LineEdit ()
 Destruct.
virtual void ApplyAttributes ()
 Apply attribute changes that can not be applied immediately.
virtual void Update (float timeStep)
 Perform UI element update.
virtual void OnClick (const IntVector2 &position, const IntVector2 &screenPosition, int buttons, int qualifiers, Cursor *cursor)
 React to mouse click.
virtual void OnDragBegin (const IntVector2 &position, const IntVector2 &screenPosition, int buttons, int qualifiers, Cursor *cursor)
 React to mouse drag begin.
virtual void OnDragMove (const IntVector2 &position, const IntVector2 &screenPosition, int buttons, int qualifiers, Cursor *cursor)
 React to mouse drag motion.
virtual bool OnDragDropTest (UIElement *source)
 React to drag and drop test. Return true to signal that the drop is acceptable.
virtual bool OnDragDropFinish (UIElement *source)
 React to drag and drop finish. Return true to signal that the drop was accepted.
virtual void OnKey (int key, int buttons, int qualifiers)
 React to a key press.
virtual void OnChar (unsigned c, int buttons, int qualifiers)
 React to a key press translated to a character.
void SetText (const String &text)
 Set text.
void SetCursorPosition (unsigned position)
 Set cursor position.
void SetCursorBlinkRate (float rate)
 Set cursor blink rate. 0 disables blinking.
void SetMaxLength (unsigned length)
 Set maximum text length. 0 for unlimited.
void SetEchoCharacter (unsigned c)
 Set echo character for password entry and such. 0 (default) shows the actual text.
void SetCursorMovable (bool enable)
 Set whether can move cursor with arrows or mouse, default true.
void SetTextSelectable (bool enable)
 Set whether selections are allowed, default true.
void SetTextCopyable (bool enable)
 Set whether copy-paste operations are allowed, default true.
const StringGetText () const
 Return text.
unsigned GetCursorPosition () const
 Return cursor position.
float GetCursorBlinkRate () const
 Return cursor blink rate.
unsigned GetMaxLength () const
 Return maximum text length.
unsigned GetEchoCharacter () const
 Return echo character.
bool IsCursorMovable () const
 Return whether can move cursor with arrows or mouse.
bool IsTextSelectable () const
 Return whether selections are allowed.
bool IsTextCopyable () const
 Return whether copy-paste operations are allowed.
TextGetTextElement () const
 Return text element.
BorderImageGetCursor () const
 Return cursor element.
- Public Member Functions inherited from Urho3D::BorderImage
 BorderImage (Context *context)
 Construct.
virtual ~BorderImage ()
 Destruct.
virtual void GetBatches (PODVector< UIBatch > &batches, PODVector< UIQuad > &quads, const IntRect &currentScissor)
 Return UI rendering batches.
void SetTexture (Texture *texture)
 Set textures.
void SetImageRect (const IntRect &rect)
 Set part of texture to use as the image.
void SetFullImageRect ()
 Use whole texture as the image.
void SetBorder (const IntRect &rect)
 Set image border dimensions.
void SetHoverOffset (const IntVector2 &offset)
 Set offset to image rectangle used on hover.
void SetHoverOffset (int x, int y)
 Set offset to image rectangle used on hover.
void SetTiled (bool enable)
 Set tiled.
bool IsTiled () const
 Return whether is tiled.
TextureGetTexture () const
 Return texture.
const IntRectGetImageRect () const
 Return image rectangle.
const IntRectGetBorder () const
 Return image border dimensions.
const IntVector2GetHoverOffset () const
 Return offset to image rectangle used on hover.
void SetTextureAttr (ResourceRef value)
 Set texture attribute.
ResourceRef GetTextureAttr () const
 Return texture attribute.
- Public Member Functions inherited from Urho3D::UIElement
 UIElement (Context *context)
 Construct.
virtual ~UIElement ()
 Destruct.
virtual bool LoadXML (const XMLElement &source)
 Load from XML data. Return true if successful.
virtual bool LoadXML (const XMLElement &source, XMLFile *styleFile)
 Load from XML data with style. Return true if successful.
virtual bool SaveXML (XMLElement &dest)
 Save as XML data. Return true if successful.
virtual void OnHover (const IntVector2 &position, const IntVector2 &screenPosition, int buttons, int qualifiers, Cursor *cursor)
 React to mouse hover.
virtual void OnDragEnd (const IntVector2 &position, const IntVector2 &screenPosition, Cursor *cursor)
 React to mouse drag end.
virtual void OnWheel (int delta, int buttons, int qualifiers)
 React to mouse wheel.
virtual void OnResize ()
 React to resize.
bool LoadXML (Deserializer &source)
 Load from an XML file. Return true if successful.
bool SaveXML (Serializer &dest)
 Save to an XML file. Return true if successful.
void SetName (const String &name)
 Set name.
void SetPosition (const IntVector2 &position)
 Set position.
void SetPosition (int x, int y)
 Set position.
void SetSize (const IntVector2 &size)
 Set size.
void SetSize (int width, int height)
 Set size.
void SetWidth (int width)
 Set width only.
void SetHeight (int height)
 Set height only.
void SetMinSize (const IntVector2 &minSize)
 Set minimum size.
void SetMinSize (int width, int height)
 Set minimum size.
void SetMinWidth (int width)
 Set minimum width.
void SetMinHeight (int height)
 Set minimum height.
void SetMaxSize (const IntVector2 &maxSize)
 Set maximum size.
void SetMaxSize (int width, int height)
 Set maximum size.
void SetMaxWidth (int width)
 Set maximum width.
void SetMaxHeight (int height)
 Set maximum height.
void SetFixedSize (const IntVector2 &size)
 Set fixed size.
void SetFixedSize (int width, int height)
 Set fixed size.
void SetFixedWidth (int width)
 Set fixed width.
void SetFixedHeight (int height)
 Set fixed height.
void SetAlignment (HorizontalAlignment hAlign, VerticalAlignment vAlign)
 Set horizontal and vertical alignment.
void SetHorizontalAlignment (HorizontalAlignment align)
 Set horizontal alignment.
void SetVerticalAlignment (VerticalAlignment align)
 Set vertical alignment.
void SetClipBorder (const IntRect &rect)
 Set child element clipping border.
void SetColor (const Color &color)
 Set color on all corners.
void SetColor (Corner corner, const Color &color)
 Set color on one corner.
void SetPriority (int priority)
 Set priority.
void SetOpacity (float opacity)
 Set opacity.
void SetBringToFront (bool enable)
 Set whether should be brought to front when focused.
void SetBringToBack (bool enable)
 Set whether should be put to background when another element is focused.
void SetClipChildren (bool enable)
 Set whether should clip child elements. Default false.
void SetSortChildren (bool enable)
 Set whether should sort child elements according to priority. Default true.
void SetActive (bool enable)
 Set whether reacts to input.
void SetFocus (bool enable)
 Set whether is focused. Only one element can be focused at a time.
void SetSelected (bool enable)
 Set selected mode. Actual meaning is element dependent, for example constant hover or pressed effect.
void SetVisible (bool enable)
 Set whether is visible.
void SetFocusMode (FocusMode mode)
 Set focus mode.
void SetDragDropMode (unsigned mode)
 Set drag and drop flags.
void SetStyle (XMLFile *file, const String &typeName)
 Set style from an XML file. Find the style element by name.
void SetStyle (const XMLElement &element)
 Set style from an XML element.
void SetStyleAuto (XMLFile *file)
 Set style from an XML file. Find the style element automatically.
void SetLayout (LayoutMode mode, int spacing=0, const IntRect &border=IntRect::ZERO)
 Set layout.
void SetLayoutMode (LayoutMode mode)
 Set layout mode only.
void SetLayoutSpacing (int spacing)
 Set layout spacing.
void SetLayoutBorder (const IntRect &border)
 Set layout border.
void UpdateLayout ()
 Manually update layout. Should not be necessary in most cases, but is provided for completeness.
void DisableLayoutUpdate ()
 Disable automatic layout update. Should only be used if there are performance problems.
void EnableLayoutUpdate ()
 Enable automatic layout update.
void BringToFront ()
 Bring UI element to front.
UIElementCreateChild (ShortStringHash type, const String &name=String())
 Create and add a child element and return it.
void AddChild (UIElement *element)
 Add a child element.
void InsertChild (unsigned index, UIElement *element)
 Insert a child element into a specific position in the child list.
void RemoveChild (UIElement *element, unsigned index=0)
 Remove a child element. Starting search at specified index if provided.
void RemoveAllChildren ()
 Remove all child elements.
void Remove ()
 Remove from the parent element. If no other shared pointer references exist, causes immediate deletion.
void SetParent (UIElement *parent)
 Set parent element. Same as parent->AddChild(this).
void SetVar (ShortStringHash key, const Variant &value)
 Set a user variable.
void SetInternal (bool enable)
 Mark as internally (programmatically) created. Used when an element composes itself out of child elements.
template<class T >
T * CreateChild (const String &name=String())
 Template version of creating a child element.
const StringGetName () const
 Return name.
const IntVector2GetPosition () const
 Return position.
IntVector2 GetScreenPosition () const
 Return screen position.
const IntVector2GetSize () const
 Return size.
int GetWidth () const
 Return width.
int GetHeight () const
 Return height.
const IntVector2GetMinSize () const
 Return minimum size.
int GetMinWidth () const
 Return minimum width.
int GetMinHeight () const
 Return minimum height.
const IntVector2GetMaxSize () const
 Return maximum size.
int GetMaxWidth () const
 Return minimum width.
int GetMaxHeight () const
 Return minimum height.
const IntVector2GetChildOffset () const
 Return child element offset.
HorizontalAlignment GetHorizontalAlignment () const
 Return horizontal alignment.
VerticalAlignment GetVerticalAlignment () const
 Return vertical alignment.
const IntRectGetClipBorder () const
 Return child element clipping border.
const ColorGetColor (Corner corner) const
 Return corner color.
int GetPriority () const
 Return priority.
float GetOpacity () const
 Return opacity.
float GetDerivedOpacity () const
 Return derived opacity (affected by parent elements.)
bool GetBringToFront () const
 Return whether should be brought to front when focused.
bool GetBringToBack () const
 Return whether should be put to background when another element is focused.
bool GetClipChildren () const
 Return whether should clip child elements.
bool GetSortChildren () const
 Return whether should sort child elements according to priority.
bool HasFocus () const
 Return whether has focus.
bool IsActive () const
 Return whether reacts to input.
bool IsSelected () const
 Return whether is selected. Actual meaning is element dependent.
bool IsVisible () const
 Return whether is visible.
bool IsHovering () const
 Return whether the cursor is hovering on this element.
bool IsInternal () const
 Return whether is internally created.
bool HasColorGradient () const
 Return whether has different color in at least one corner.
FocusMode GetFocusMode () const
 Return focus mode.
unsigned GetDragDropMode () const
 Return drag and drop flags.
LayoutMode GetLayoutMode () const
 Return layout mode.
int GetLayoutSpacing () const
 Return layout spacing.
const IntRectGetLayoutBorder () const
 Return layout border.
unsigned GetNumChildren (bool recursive=false) const
 Return number of child elements.
UIElementGetChild (unsigned index) const
 Return child element by index.
UIElementGetChild (const String &name, bool recursive=false) const
 Return child element by name.
const Vector< SharedPtr
< UIElement > > & 
GetChildren () const
 Return immediate child elements.
void GetChildren (PODVector< UIElement * > &dest, bool recursive=false) const
 Return child elements either recursively or non-recursively.
UIElementGetParent () const
 Return parent element.
UIElementGetRoot () const
 Return root element.
const ColorGetDerivedColor () const
 Return derived color. Only valid when no gradient.
const VariantGetVar (ShortStringHash key) const
 Return a user variable.
const VariantMapGetVars () const
 Return all user variables.
IntVector2 ScreenToElement (const IntVector2 &screenPosition)
 Convert screen coordinates to element coordinates.
IntVector2 ElementToScreen (const IntVector2 &position)
 Convert element coordinates to screen coordinates.
bool IsInside (IntVector2 position, bool isScreen)
 Return whether a point (either in element or screen coordinates) is inside the element.
bool IsInsideCombined (IntVector2 position, bool isScreen)
 Return whether a point (either in element or screen coordinates) is inside the combined rect of the element and its children.
IntRect GetCombinedScreenRect ()
 Return combined screen coordinate rect of element and its children.
void SortChildren ()
 Sort child elements if sorting enabled and order dirty. Called by UI.
int GetLayoutMinSize () const
 Return minimum layout element size in the layout direction. Only valid after layout has been calculated.
void SetChildOffset (const IntVector2 &offset)
 Set child offset.
void SetHovering (bool enable)
 Set hovering state.
void SetTempVisible (bool enable)
 Set temporary visibility status without updating layout or sending events. Used internally.
void AdjustScissor (IntRect &currentScissor)
 Adjust scissor for rendering.
void GetBatchesWithOffset (IntVector2 &offset, PODVector< UIBatch > &batches, PODVector< UIQuad > &quads, IntRect currentScissor)
 Get UI rendering batches with a specified offset. Also recurses to child elements.
- Public Member Functions inherited from Urho3D::Serializable
 Serializable (Context *context)
 Construct.
virtual ~Serializable ()
 Destruct.
virtual void OnSetAttribute (const AttributeInfo &attr, const Variant &src)
 Handle attribute write access. Default implementation writes to the variable at offset, or invokes the set accessor.
virtual void OnGetAttribute (const AttributeInfo &attr, Variant &dest)
 Handle attribute read access. Default implementation reads the variable at offset, or invokes the get accessor.
virtual bool Load (Deserializer &source)
 Load from binary data. Return true if successful.
virtual bool Save (Serializer &dest)
 Save as binary data. Return true if successful.
bool SetAttribute (unsigned index, const Variant &value)
 Set attribute by index. Return true if successfully set.
bool SetAttribute (const String &name, const Variant &value)
 Set attribute by name. Return true if successfully set.
void AllocateNetworkState ()
 Allocate network attribute state.
void WriteInitialDeltaUpdate (Serializer &dest)
 Write initial delta network update.
void WriteDeltaUpdate (Serializer &dest, const DirtyBits &attributeBits)
 Write a delta network update according to dirty attribute bits.
void WriteLatestDataUpdate (Serializer &dest)
 Write a latest data network update.
void ReadDeltaUpdate (Deserializer &source)
 Read and apply a network delta update.
void ReadLatestDataUpdate (Deserializer &source)
 Read and apply a network latest data update.
Variant GetAttribute (unsigned index)
 Return attribute value by index. Return empty if illegal index.
Variant GetAttribute (const String &name)
 Return attribute value by name. Return empty if not found.
unsigned GetNumAttributes () const
 Return number of attributes.
unsigned GetNumNetworkAttributes () const
 Return number of network replication attributes.
const Vector< AttributeInfo > * GetAttributes () const
 Return attribute descriptions, or null if none defined.
const Vector< AttributeInfo > * GetNetworkAttributes () const
 Return network replication attribute descriptions, or null if none defined.
- Public Member Functions inherited from Urho3D::Object
 Object (Context *context)
 Construct.
virtual ~Object ()
 Destruct. Clean up self from event sender & receiver structures.
virtual ShortStringHash GetType () const =0
 Return type hash.
virtual const StringGetTypeName () const =0
 Return type name.
virtual void OnEvent (Object *sender, StringHash eventType, VariantMap &eventData)
 Handle event.
void SubscribeToEvent (StringHash eventType, EventHandler *handler)
 Subscribe to an event that can be sent by any sender.
void SubscribeToEvent (Object *sender, StringHash eventType, EventHandler *handler)
 Subscribe to a specific sender's event.
void UnsubscribeFromEvent (StringHash eventType)
 Unsubscribe from an event.
void UnsubscribeFromEvent (Object *sender, StringHash eventType)
 Unsubscribe from a specific sender's event.
void UnsubscribeFromEvents (Object *sender)
 Unsubscribe from a specific sender's events.
void UnsubscribeFromAllEvents ()
 Unsubscribe from all events.
void UnsubscribeFromAllEventsExcept (const PODVector< StringHash > &exceptions, bool onlyUserData)
 Unsubscribe from all events except those listed, and optionally only those with userdata (script registered events.)
void SendEvent (StringHash eventType)
 Send event to all subscribers.
void SendEvent (StringHash eventType, VariantMap &eventData)
 Send event with parameters to all subscribers.
ContextGetContext () const
 Return execution context.
ObjectGetSubsystem (ShortStringHash type) const
 Return subsystem by type.
ObjectGetEventSender () const
 Return active event sender. Null outside event handling.
EventHandlerGetEventHandler () const
 Return active event handler. Null outside event handling.
bool HasSubscribedToEvent (StringHash eventType) const
 Return whether has subscribed to an event without specific sender.
bool HasSubscribedToEvent (Object *sender, StringHash eventType) const
 Return whether has subscribed to a specific sender's event.
template<class T >
T * GetSubsystem () const
 Template version of returning a subsystem.
- Public Member Functions inherited from Urho3D::RefCounted
 RefCounted ()
 Construct. Allocate the reference count structure and set an initial self weak reference.
virtual ~RefCounted ()
 Destruct. Mark as expired and also delete the reference count structure if no outside weak references exist.
void AddRef ()
 Increment reference count. Can also be called outside of a SharedPtr for traditional reference counting.
void ReleaseRef ()
 Decrement reference count and delete self if no more references. Can also be called outside of a SharedPtr for traditional reference counting.
int Refs () const
 Return reference count.
int WeakRefs () const
 Return weak reference count.
RefCountRefCountPtr ()
 Return pointer to the reference count structure.

Static Public Member Functions

static void RegisterObject (Context *context)
 Register object factory.

Protected Member Functions

void UpdateText ()
 Update displayed text.
void UpdateCursor ()
 Update cursor position and restart cursor blinking.
unsigned GetCharIndex (const IntVector2 &position)
 Return char index corresponding to position within element, or M_MAX_UNSIGNED if not found.
- Protected Member Functions inherited from Urho3D::BorderImage
void GetBatches (PODVector< UIBatch > &batches, PODVector< UIQuad > &quads, const IntRect &currentScissor, const IntVector2 &offset)
 Return UI rendering batches with offset to image rectangle.
- Protected Member Functions inherited from Urho3D::UIElement
void MarkDirty ()
 Mark screen position as needing an update.

Protected Attributes

SharedPtr< Texttext_
 Text element.
SharedPtr< BorderImagecursor_
 Cursor element.
String line_
 Text line.
FontlastFont_
 Last used text font.
int lastFontSize_
 Last used text size.
unsigned cursorPosition_
 Text edit cursor position.
unsigned dragBeginCursor_
 Drag begin cursor position.
float cursorBlinkRate_
 Cursor blink rate.
float cursorBlinkTimer_
 Cursor blink timer.
unsigned maxLength_
 Maximum text length.
unsigned echoCharacter_
 Echo character.
bool cursorMovable_
 Cursor movable flag.
bool textSelectable_
 Text selectable flag.
bool textCopyable_
 Copy-paste enable flag.
- Protected Attributes inherited from Urho3D::BorderImage
SharedPtr< Texturetexture_
 Texture.
IntRect imageRect_
 Image rectangle.
IntRect border_
 Image border dimensions.
IntVector2 hoverOffset_
 Offset to image rectangle on hover.
bool tiled_
 Tiled flag.
- Protected Attributes inherited from Urho3D::UIElement
String name_
 Name.
Vector< SharedPtr< UIElement > > children_
 Child elements.
UIElementparent_
 Parent element.
IntRect clipBorder_
 Child element clipping border.
Color color_ [MAX_UIELEMENT_CORNERS]
 Colors.
VariantMap vars_
 User variables.
int priority_
 Priority.
bool bringToFront_
 Bring to front when focused flag.
bool bringToBack_
 Bring to back when defocused flag.
bool clipChildren_
 Clip children flag.
bool sortChildren_
 Sort childrenaccording to priority flag.
bool active_
 Input enabled flag.
bool selected_
 Selected flag.
bool visible_
 Visible flag.
bool hovering_
 Hovering flag.
bool internal_
 Internally created flag.
FocusMode focusMode_
 Focus mode.
unsigned dragDropMode_
 Drag and drop flags.
LayoutMode layoutMode_
 Layout mode.
int layoutSpacing_
 Layout spacing.
IntRect layoutBorder_
 Layout borders.
unsigned resizeNestingLevel_
 Resize nesting level to prevent multiple events and endless loop.
unsigned layoutNestingLevel_
 Layout update nesting level to prevent endless loop.
int layoutMinSize_
 Layout element minimum size in layout direction.
- Protected Attributes inherited from Urho3D::Serializable
NetworkStatenetworkState_
 Network attribute state.
- Protected Attributes inherited from Urho3D::Object
Contextcontext_
 Execution context.

Private Member Functions

 OBJECT (LineEdit)
void HandleFocused (StringHash eventType, VariantMap &eventData)
 Handle being focused.
void HandleDefocused (StringHash eventType, VariantMap &eventData)
 Handle being defocused.

Detailed Description

Single-line text editor UI element.


The documentation for this class was generated from the following files: