Ver Fonte

Added editable flag to UI elements. When disabled, will not edit the value (eg. LineEdit text) through user input. Fixes #4.
Moved UIElement default virtual function implementations to the header.
Removed clip border from the default style LineEdit, as some letters (eg. lowercase y) will clip with the font size used in the editor & console.

Lasse Öörni há 12 anos atrás
pai
commit
39c8295eb3

+ 1 - 1
Bin/Data/Scripts/Editor/AttributeEditor.as

@@ -31,7 +31,7 @@ UIElement@ SetEditable(UIElement@ element, bool editable)
     if (element is null)
         return element;
 
-    element.enabled = editable;
+    element.editable = editable;
     element.colors[C_TOPLEFT] = editable ? element.colors[C_BOTTOMRIGHT] : nonEditableTextColor;
     element.colors[C_BOTTOMLEFT] = element.colors[C_TOPLEFT];
     element.colors[C_TOPRIGHT] = element.colors[C_TOPLEFT];

+ 1 - 1
Bin/Data/UI/DefaultStyle.xml

@@ -84,7 +84,7 @@
     </element>
     <element type="LineEdit" style="BorderImage">
         <attribute name="Border" value="4 4 4 4" />
-        <attribute name="Clip Border" value="2 2 2 2" />
+        <attribute name="Clip Border" value="0 0 0 0" />
         <attribute name="Image Rect" value="64 0 80 16" />
         <attribute name="Hover Image Offset" value="0 16" />    <!-- Background color of the hover image IS the hover color of LineEdit -->
         <element type="Text" internal="true">

+ 7 - 1
Docs/LuaScriptAPI.dox

@@ -4877,6 +4877,7 @@ Methods:
 - void SetClipBoardText(const String text)
 - void SetDoubleClickInterval(float interval)
 - void SetNonFocusedMouseWheel(bool nonFocusedMouseWheel)
+- void SetUseSystemClipBoard(bool enable)
 - UIElement* GetRoot() const
 - UIElement* GetRootModalElement() const
 - Cursor* GetCursor() const
@@ -4888,6 +4889,7 @@ Methods:
 - const String& GetClipBoardText() const
 - float GetDoubleClickInterval() const
 - bool IsNonFocusedMouseWheel() const
+- bool GetUseSystemClipBoard() const
 - bool HasModalElement() const
 
 Properties:
@@ -4900,7 +4902,8 @@ Properties:
 - IntVector2 cursorPosition (readonly)
 - String& clipBoardText
 - float doubleClickInterval
-- bool nonFocusedMouseWheel (readonly)
+- bool nonFocusedMouseWheel
+- bool useSystemClipBoard
 - bool modalElement (readonly)
 
 ### UIElement : Serializable
@@ -4946,6 +4949,7 @@ Methods:
 - void SetSortChildren(bool enable)
 - void SetUseDerivedOpacity(bool enable)
 - void SetEnabled(bool enable)
+- void SetEditable(bool enable)
 - void SetFocus(bool enable)
 - void SetSelected(bool enable)
 - void SetVisible(bool enable)
@@ -5007,6 +5011,7 @@ Methods:
 - bool GetUseDerivedOpacity() const
 - bool HasFocus() const
 - bool IsEnabled() const
+- bool IsEditable() const
 - bool IsSelected() const
 - bool IsVisible() const
 - bool IsHovering() const
@@ -5075,6 +5080,7 @@ Properties:
 - bool useDerivedOpacity
 - bool focus
 - bool enabled
+- bool editable
 - bool selected
 - bool visible
 - bool hovering

+ 16 - 0
Docs/ScriptAPI.dox

@@ -4125,6 +4125,7 @@ Properties:
 - bool sortChildren
 - bool useDerivedOpacity
 - bool enabled
+- bool editable
 - bool focus
 - bool selected
 - bool visible
@@ -4252,6 +4253,7 @@ Properties:
 - bool sortChildren
 - bool useDerivedOpacity
 - bool enabled
+- bool editable
 - bool focus
 - bool selected
 - bool visible
@@ -4487,6 +4489,7 @@ Properties:
 - bool sortChildren
 - bool useDerivedOpacity
 - bool enabled
+- bool editable
 - bool focus
 - bool selected
 - bool visible
@@ -4626,6 +4629,7 @@ Properties:
 - bool sortChildren
 - bool useDerivedOpacity
 - bool enabled
+- bool editable
 - bool focus
 - bool selected
 - bool visible
@@ -4762,6 +4766,7 @@ Properties:
 - bool sortChildren
 - bool useDerivedOpacity
 - bool enabled
+- bool editable
 - bool focus
 - bool selected
 - bool visible
@@ -4898,6 +4903,7 @@ Properties:
 - bool sortChildren
 - bool useDerivedOpacity
 - bool enabled
+- bool editable
 - bool focus
 - bool selected
 - bool visible
@@ -5037,6 +5043,7 @@ Properties:
 - bool sortChildren
 - bool useDerivedOpacity
 - bool enabled
+- bool editable
 - bool focus
 - bool selected
 - bool visible
@@ -5173,6 +5180,7 @@ Properties:
 - bool sortChildren
 - bool useDerivedOpacity
 - bool enabled
+- bool editable
 - bool focus
 - bool selected
 - bool visible
@@ -5325,6 +5333,7 @@ Properties:
 - bool sortChildren
 - bool useDerivedOpacity
 - bool enabled
+- bool editable
 - bool focus
 - bool selected
 - bool visible
@@ -5473,6 +5482,7 @@ Properties:
 - bool sortChildren
 - bool useDerivedOpacity
 - bool enabled
+- bool editable
 - bool focus
 - bool selected
 - bool visible
@@ -5687,6 +5697,7 @@ Properties:
 - bool sortChildren
 - bool useDerivedOpacity
 - bool enabled
+- bool editable
 - bool focus
 - bool selected
 - bool visible
@@ -5835,6 +5846,7 @@ Properties:
 - bool sortChildren
 - bool useDerivedOpacity
 - bool enabled
+- bool editable
 - bool focus
 - bool selected
 - bool visible
@@ -5989,6 +6001,7 @@ Properties:
 - bool sortChildren
 - bool useDerivedOpacity
 - bool enabled
+- bool editable
 - bool focus
 - bool selected
 - bool visible
@@ -6136,6 +6149,7 @@ Properties:
 - bool sortChildren
 - bool useDerivedOpacity
 - bool enabled
+- bool editable
 - bool focus
 - bool selected
 - bool visible
@@ -6272,6 +6286,7 @@ Properties:
 - bool sortChildren
 - bool useDerivedOpacity
 - bool enabled
+- bool editable
 - bool focus
 - bool selected
 - bool visible
@@ -6382,6 +6397,7 @@ Properties:
 - String clipBoardText
 - float doubleClickInterval
 - bool nonFocusedMouseWheel
+- bool useSystemClipBoard
 
 
 ### Controls

+ 2 - 0
Source/Engine/Script/APITemplates.h

@@ -988,6 +988,8 @@ template <class T> void RegisterUIElement(asIScriptEngine* engine, const char* c
     {
         engine->RegisterObjectMethod(className, "void set_enabled(bool)", asMETHOD(T, SetEnabled), asCALL_THISCALL);
         engine->RegisterObjectMethod(className, "bool get_enabled() const", asMETHOD(T, IsEnabled), asCALL_THISCALL);
+        engine->RegisterObjectMethod(className, "void set_editable(bool)", asMETHOD(T, SetEditable), asCALL_THISCALL);
+        engine->RegisterObjectMethod(className, "bool get_editable() const", asMETHOD(T, IsEditable), asCALL_THISCALL);
         engine->RegisterObjectMethod(className, "void set_focus(bool)", asMETHOD(T, SetFocus), asCALL_THISCALL);
         engine->RegisterObjectMethod(className, "bool get_focus() const", asMETHOD(T, HasFocus), asCALL_THISCALL);
         engine->RegisterObjectMethod(className, "void set_selected(bool)", asMETHOD(T, SetSelected), asCALL_THISCALL);

+ 1 - 1
Source/Engine/UI/CheckBox.cpp

@@ -68,7 +68,7 @@ void CheckBox::GetBatches(PODVector<UIBatch>& batches, PODVector<float>& vertexD
 
 void CheckBox::OnClickBegin(const IntVector2& position, const IntVector2& screenPosition, int button, int buttons, int qualifiers, Cursor* cursor)
 {
-    if (button == MOUSEB_LEFT)
+    if (button == MOUSEB_LEFT && editable_)
         SetChecked(!checked_);
 }
 

+ 5 - 0
Source/Engine/UI/DropDownList.cpp

@@ -126,6 +126,11 @@ void DropDownList::OnShowPopup()
     SetPopupOffset(0, showAbove ? -popup_->GetHeight() : GetHeight());
 }
 
+void DropDownList::OnSetEditable()
+{
+    listView_->SetEditable(editable_);
+}
+
 void DropDownList::AddItem(UIElement* item)
 {
     InsertItem(M_MAX_UNSIGNED, item);

+ 3 - 1
Source/Engine/UI/DropDownList.h

@@ -48,7 +48,9 @@ public:
     virtual void GetBatches(PODVector<UIBatch>& batches, PODVector<float>& vertexData, const IntRect& currentScissor);
     /// React to the popup being shown.
     virtual void OnShowPopup();
-
+    /// React to editable status change.
+    virtual void OnSetEditable();
+    
     /// Add item to the end of the list.
     void AddItem(UIElement* item);
     /// Insert item to a specific position.

+ 48 - 39
Source/Engine/UI/LineEdit.cpp

@@ -166,7 +166,7 @@ bool LineEdit::OnDragDropTest(UIElement* source)
 
 bool LineEdit::OnDragDropFinish(UIElement* source)
 {
-    if (source)
+    if (source && editable_)
     {
         ShortStringHash sourceType = source->GetType();
         if (sourceType == LineEdit::GetTypeStatic())
@@ -203,7 +203,7 @@ void LineEdit::OnKey(int key, int buttons, int qualifiers)
             if (text_->GetSelectionLength())
                 GetSubsystem<UI>()->SetClipBoardText(line_.SubstringUTF8(start, length));
 
-            if (key == 'X')
+            if (key == 'X' && editable_)
             {
                 if (start + length < line_.LengthUTF8())
                     line_ = line_.SubstringUTF8(0, start) + line_.SubstringUTF8(start + length);
@@ -217,7 +217,7 @@ void LineEdit::OnKey(int key, int buttons, int qualifiers)
         break;
 
     case 'V':
-        if (textCopyable_ && qualifiers & QUAL_CTRL)
+        if (editable_ && textCopyable_ && qualifiers & QUAL_CTRL)
         {
             const String& clipBoard = GetSubsystem<UI>()->GetClipBoardText();
             if (!clipBoard.Empty())
@@ -305,26 +305,29 @@ void LineEdit::OnKey(int key, int buttons, int qualifiers)
         break;
 
     case KEY_DELETE:
-        if (!text_->GetSelectionLength())
+        if (editable_)
         {
-            if (cursorPosition_ < line_.LengthUTF8())
+            if (!text_->GetSelectionLength())
             {
-                line_ = line_.SubstringUTF8(0, cursorPosition_) + line_.SubstringUTF8(cursorPosition_ + 1);
-                changed = true;
+                if (cursorPosition_ < line_.LengthUTF8())
+                {
+                    line_ = line_.SubstringUTF8(0, cursorPosition_) + line_.SubstringUTF8(cursorPosition_ + 1);
+                    changed = true;
+                }
             }
-        }
-        else
-        {
-            // If a selection exists, erase it
-            unsigned start = text_->GetSelectionStart();
-            unsigned length = text_->GetSelectionLength();
-            if (start + length < line_.LengthUTF8())
-                line_ = line_.SubstringUTF8(0, start) + line_.SubstringUTF8(start + length);
             else
-                line_ = line_.SubstringUTF8(0, start);
-            text_->ClearSelection();
-            cursorPosition_ = start;
-            changed = true;
+            {
+                // If a selection exists, erase it
+                unsigned start = text_->GetSelectionStart();
+                unsigned length = text_->GetSelectionLength();
+                if (start + length < line_.LengthUTF8())
+                    line_ = line_.SubstringUTF8(0, start) + line_.SubstringUTF8(start + length);
+                else
+                    line_ = line_.SubstringUTF8(0, start);
+                text_->ClearSelection();
+                cursorPosition_ = start;
+                changed = true;
+            }
         }
         break;
 
@@ -345,31 +348,34 @@ void LineEdit::OnKey(int key, int buttons, int qualifiers)
         return;
 
     case KEY_BACKSPACE:
-        if (!text_->GetSelectionLength())
+        if (editable_)
         {
-            if (line_.LengthUTF8() && cursorPosition_)
+            if (!text_->GetSelectionLength())
             {
-                if (cursorPosition_ < line_.LengthUTF8())
-                    line_ = line_.SubstringUTF8(0, cursorPosition_ - 1) + line_.SubstringUTF8(cursorPosition_);
+                if (line_.LengthUTF8() && cursorPosition_)
+                {
+                    if (cursorPosition_ < line_.LengthUTF8())
+                        line_ = line_.SubstringUTF8(0, cursorPosition_ - 1) + line_.SubstringUTF8(cursorPosition_);
+                    else
+                        line_ = line_.SubstringUTF8(0, cursorPosition_ - 1);
+                    --cursorPosition_;
+                    changed = true;
+                }
+            }
+            else
+            {
+                // If a selection exists, erase it
+                unsigned start = text_->GetSelectionStart();
+                unsigned length = text_->GetSelectionLength();
+                if (start + length < line_.LengthUTF8())
+                    line_ = line_.SubstringUTF8(0, start) + line_.SubstringUTF8(start + length);
                 else
-                    line_ = line_.SubstringUTF8(0, cursorPosition_ - 1);
-                --cursorPosition_;
+                    line_ = line_.SubstringUTF8(0, start);
+                text_->ClearSelection();
+                cursorPosition_ = start;
                 changed = true;
             }
         }
-        else
-        {
-            // If a selection exists, erase it
-            unsigned start = text_->GetSelectionStart();
-            unsigned length = text_->GetSelectionLength();
-            if (start + length < line_.LengthUTF8())
-                line_ = line_.SubstringUTF8(0, start) + line_.SubstringUTF8(start + length);
-            else
-                line_ = line_.SubstringUTF8(0, start);
-            text_->ClearSelection();
-            cursorPosition_ = start;
-            changed = true;
-        }
         break;
 
     case KEY_RETURN:
@@ -398,8 +404,11 @@ void LineEdit::OnKey(int key, int buttons, int qualifiers)
 
 void LineEdit::OnChar(unsigned c, int buttons, int qualifiers)
 {
+    if (!editable_)
+        return;
+    
     bool changed = false;
-
+    
     // If only CTRL is held down, do not edit
     if ((qualifiers & (QUAL_CTRL | QUAL_ALT)) == QUAL_CTRL)
         return;

+ 7 - 0
Source/Engine/UI/ListView.cpp

@@ -923,6 +923,13 @@ void ListView::HandleUIMouseClick(StringHash eventType, VariantMap& eventData)
 
     UIElement* element = static_cast<UIElement*>(eventData[UIMouseClick::P_ELEMENT].GetPtr());
 
+    // If not editable, repeat the previous selection. This will send an event and allow eg. a dropdownlist to close
+    if (!editable_)
+    {
+        SetSelections(selections_);
+        return;
+    }
+
     unsigned numItems = GetNumItems();
     for (unsigned i = 0; i < numItems; ++i)
     {

+ 9 - 2
Source/Engine/UI/ScrollBar.cpp

@@ -127,6 +127,11 @@ void ScrollBar::OnResize()
     EnableLayoutUpdate();
 }
 
+void ScrollBar::OnSetEditable()
+{
+    slider_->SetEditable(editable_);
+}
+
 void ScrollBar::SetOrientation(Orientation orientation)
 {
     slider_->SetOrientation(orientation);
@@ -259,12 +264,14 @@ bool ScrollBar::FilterButtonImplicitAttributes(XMLElement& dest, const String& n
 
 void ScrollBar::HandleBackButtonPressed(StringHash eventType, VariantMap& eventData)
 {
-    StepBack();
+    if (editable_)
+        StepBack();
 }
 
 void ScrollBar::HandleForwardButtonPressed(StringHash eventType, VariantMap& eventData)
 {
-    StepForward();
+    if (editable_)
+        StepForward();
 }
 
 void ScrollBar::HandleSliderChanged(StringHash eventType, VariantMap& eventData)

+ 2 - 0
Source/Engine/UI/ScrollBar.h

@@ -47,6 +47,8 @@ public:
     virtual void ApplyAttributes();
     /// React to resize.
     virtual void OnResize();
+    /// React to editable status change.
+    virtual void OnSetEditable();
     
     /// Set orientation type.
     void SetOrientation(Orientation orientation);

+ 4 - 1
Source/Engine/UI/Slider.cpp

@@ -123,7 +123,7 @@ void Slider::OnDragBegin(const IntVector2& position, const IntVector2& screenPos
 
 void Slider::OnDragMove(const IntVector2& position, const IntVector2& screenPosition, int buttons, int qualifiers, Cursor* cursor)
 {
-    if (!dragSlider_ || GetSize() == knob_->GetSize())
+    if (!editable_ || !dragSlider_ || GetSize() == knob_->GetSize())
         return;
 
     float newValue = value_;
@@ -247,6 +247,9 @@ void Slider::UpdateSlider()
 
 void Slider::Page(const IntVector2& position, bool pressed)
 {
+    if (!editable_)
+        return;
+    
     IntVector2 offsetXY = position - knob_->GetPosition() - knob_->GetSize() / 2;
     int offset = orientation_ == O_HORIZONTAL ? offsetXY.x_ : offsetXY.y_;
     float length = (float)(orientation_ == O_HORIZONTAL ? GetWidth() : GetHeight());

+ 8 - 54
Source/Engine/UI/UIElement.cpp

@@ -119,6 +119,7 @@ UIElement::UIElement(Context* context) :
     sortChildren_(true),
     useDerivedOpacity_(true),
     enabled_(false),
+    editable_(true),
     selected_(false),
     visible_(true),
     hovering_(false),
@@ -181,6 +182,7 @@ void UIElement::RegisterObject(Context* context)
     ATTRIBUTE(UIElement, VAR_COLOR, "Bottom Left Color", color_[2], Color::WHITE, AM_FILE);
     ATTRIBUTE(UIElement, VAR_COLOR, "Bottom Right Color", color_[3], Color::WHITE, AM_FILE);
     ACCESSOR_ATTRIBUTE(UIElement, VAR_BOOL, "Is Enabled", IsEnabled, SetEnabled, bool, false, AM_FILE);
+    ACCESSOR_ATTRIBUTE(UIElement, VAR_BOOL, "Is Editable", IsEditable, SetEditable, bool, true, AM_FILE);
     ACCESSOR_ATTRIBUTE(UIElement, VAR_BOOL, "Is Selected", IsSelected, SetSelected, bool, false, AM_FILE);
     ACCESSOR_ATTRIBUTE(UIElement, VAR_BOOL, "Is Visible", IsVisible, SetVisible, bool, true, AM_FILE);
     ACCESSOR_ATTRIBUTE(UIElement, VAR_BOOL, "Bring To Front", GetBringToFront, SetBringToFront, bool, false, AM_FILE);
@@ -485,60 +487,6 @@ void UIElement::OnHover(const IntVector2& position, const IntVector2& screenPosi
     hovering_ = true;
 }
 
-void UIElement::OnClickBegin(const IntVector2& position, const IntVector2& screenPosition, int button, int buttons, int qualifiers, Cursor* cursor)
-{
-}
-
-void UIElement::OnClickEnd(const IntVector2& position, const IntVector2& screenPosition, int button, int buttons, int qualifiers, Cursor* cursor, UIElement* beginElement)
-{
-}
-
-void UIElement::OnDoubleClick(const IntVector2& position, const IntVector2& screenPosition, int button, int buttons, int qualifiers, Cursor* cursor)
-{
-}
-
-void UIElement::OnDragBegin(const IntVector2& position, const IntVector2& screenPosition, int buttons, int qualifiers, Cursor* cursor)
-{
-}
-
-void UIElement::OnDragMove(const IntVector2& position, const IntVector2& screenPosition, int buttons, int qualifiers, Cursor* cursor)
-{
-}
-
-void UIElement::OnDragEnd(const IntVector2& position, const IntVector2& screenPosition, Cursor* cursor)
-{
-}
-
-bool UIElement::OnDragDropTest(UIElement* source)
-{
-    return true;
-}
-
-bool UIElement::OnDragDropFinish(UIElement* source)
-{
-    return true;
-}
-
-void UIElement::OnWheel(int delta, int buttons, int qualifiers)
-{
-}
-
-void UIElement::OnKey(int key, int buttons, int qualifiers)
-{
-}
-
-void UIElement::OnChar(unsigned c, int buttons, int qualifiers)
-{
-}
-
-void UIElement::OnResize()
-{
-}
-
-void UIElement::OnPositionSet()
-{
-}
-
 bool UIElement::LoadXML(Deserializer& source)
 {
     SharedPtr<XMLFile> xml(new XMLFile(context_));
@@ -826,6 +774,12 @@ void UIElement::SetEnabled(bool enable)
     enabled_ = enable;
 }
 
+void UIElement::SetEditable(bool enable)
+{
+    editable_ = enable;
+    OnSetEditable();
+}
+
 void UIElement::SetFocusMode(FocusMode mode)
 {
     focusMode_ = mode;

+ 22 - 14
Source/Engine/UI/UIElement.h

@@ -147,31 +147,33 @@ public:
     /// React to mouse hover.
     virtual void OnHover(const IntVector2& position, const IntVector2& screenPosition, int buttons, int qualifiers, Cursor* cursor);
     /// React to mouse click begin.
-    virtual void OnClickBegin(const IntVector2& position, const IntVector2& screenPosition, int button, int buttons, int qualifiers, Cursor* cursor);
+    virtual void OnClickBegin(const IntVector2& position, const IntVector2& screenPosition, int button, int buttons, int qualifiers, Cursor* cursor) {}
     /// React to mouse click end.
-    virtual void OnClickEnd(const IntVector2& position, const IntVector2& screenPosition, int button, int buttons, int qualifiers, Cursor* cursor, UIElement* beginElement);
+    virtual void OnClickEnd(const IntVector2& position, const IntVector2& screenPosition, int button, int buttons, int qualifiers, Cursor* cursor, UIElement* beginElement) {}
     /// React to double mouse click.
-    virtual void OnDoubleClick(const IntVector2& position, const IntVector2& screenPosition, int button, int buttons, int qualifiers, Cursor* cursor);
+    virtual void OnDoubleClick(const IntVector2& position, const IntVector2& screenPosition, int button, int buttons, int qualifiers, Cursor* cursor) {}
     /// React to mouse drag begin.
-    virtual void OnDragBegin(const IntVector2& position, const IntVector2& screenPosition, int buttons, int qualifiers, Cursor* cursor);
+    virtual void OnDragBegin(const IntVector2& position, const IntVector2& screenPosition, int buttons, int qualifiers, Cursor* cursor) {}
     /// React to mouse drag motion.
-    virtual void OnDragMove(const IntVector2& position, const IntVector2& screenPosition, int buttons, int qualifiers, Cursor* cursor);
+    virtual void OnDragMove(const IntVector2& position, const IntVector2& screenPosition, int buttons, int qualifiers, Cursor* cursor) {}
     /// React to mouse drag end.
-    virtual void OnDragEnd(const IntVector2& position, const IntVector2& screenPosition, Cursor* cursor);
+    virtual void OnDragEnd(const IntVector2& position, const IntVector2& screenPosition, Cursor* cursor) {}
     /// React to drag and drop test. Return true to signal that the drop is acceptable.
-    virtual bool OnDragDropTest(UIElement* source);
+    virtual bool OnDragDropTest(UIElement* source) { return true; }
     /// React to drag and drop finish. Return true to signal that the drop was accepted.
-    virtual bool OnDragDropFinish(UIElement* source);
+    virtual bool OnDragDropFinish(UIElement* source) { return true; }
     /// React to mouse wheel.
-    virtual void OnWheel(int delta, int buttons, int qualifiers);
+    virtual void OnWheel(int delta, int buttons, int qualifiers) {}
     /// React to a key press.
-    virtual void OnKey(int key, int buttons, int qualifiers);
+    virtual void OnKey(int key, int buttons, int qualifiers) {}
     /// React to a key press translated to a character.
-    virtual void OnChar(unsigned c, int buttons, int qualifiers);
+    virtual void OnChar(unsigned c, int buttons, int qualifiers) {}
     /// React to resize.
-    virtual void OnResize();
+    virtual void OnResize() {}
     /// React to position change.
-    virtual void OnPositionSet();
+    virtual void OnPositionSet() {}
+    /// React to editable status change.
+    virtual void OnSetEditable() {}
 
     /// Load from an XML file. Return true if successful.
     bool LoadXML(Deserializer& source);
@@ -244,8 +246,10 @@ public:
     void SetSortChildren(bool enable);
     /// Set whether parent elements' opacity affects opacity. Default true.
     void SetUseDerivedOpacity(bool enable);
-    /// Set whether reacts to input.
+    /// Set whether reacts to input. Default false, but is enabled by subclasses if applicable.
     void SetEnabled(bool enable);
+    /// Set whether value is editable through input. Not applicable to all elements. Default true.
+    void SetEditable(bool enable);
     /// Set whether is focused. Only one element can be focused at a time.
     void SetFocus(bool enable);
     /// Set selected mode. Actual meaning is element dependent, for example constant hover or pressed effect.
@@ -372,6 +376,8 @@ public:
     bool HasFocus() const;
     /// Return whether reacts to input.
     bool IsEnabled() const { return enabled_; }
+    /// Return whether value is editable through input.
+    bool IsEditable() const { return editable_; }
     /// Return whether is selected. Actual meaning is element dependent.
     bool IsSelected() const { return selected_; }
     /// Return whether is visible.
@@ -496,6 +502,8 @@ protected:
     bool useDerivedOpacity_;
     /// Input enabled flag.
     bool enabled_;
+    /// Value editable flag.
+    bool editable_;
     /// Selected flag.
     bool selected_;
     /// Visible flag.

+ 3 - 3
Source/Extras/LuaScript/pkgs/UI/UI.pkg

@@ -13,7 +13,7 @@ class UI : public Object
     bool SaveLayout(Serializer& dest, UIElement* element);
     
     void SetClipBoardText(const String text);
-    
+
     void SetDoubleClickInterval(float interval);
     void SetNonFocusedMouseWheel(bool nonFocusedMouseWheel);
     void SetUseSystemClipBoard(bool enable);
@@ -42,7 +42,7 @@ class UI : public Object
     tolua_readonly tolua_property__get_set IntVector2 cursorPosition;
     tolua_property__get_set String& clipBoardText;
     tolua_property__get_set float doubleClickInterval;
-    tolua_readonly tolua_property__is_set bool nonFocusedMouseWheel;
-    tolua_readonly tolua_property__get_set bool useSystemClipBoard;
+    tolua_property__is_set bool nonFocusedMouseWheel;
+    tolua_property__get_set bool useSystemClipBoard;
     tolua_readonly tolua_property__has_set bool modalElement;
 };

+ 3 - 0
Source/Extras/LuaScript/pkgs/UI/UIElement.pkg

@@ -100,6 +100,7 @@ class UIElement : public Serializable
     void SetSortChildren(bool enable);
     void SetUseDerivedOpacity(bool enable);
     void SetEnabled(bool enable);
+    void SetEditable(bool enable);
     void SetFocus(bool enable);
     void SetSelected(bool enable);
     void SetVisible(bool enable);
@@ -168,6 +169,7 @@ class UIElement : public Serializable
     bool GetUseDerivedOpacity() const;
     bool HasFocus() const;
     bool IsEnabled() const;
+    bool IsEditable() const;
     bool IsSelected() const;
     bool IsVisible() const;
     bool IsHovering() const;
@@ -238,6 +240,7 @@ class UIElement : public Serializable
     tolua_property__get_set bool useDerivedOpacity;
     tolua_property__has_set bool focus;
     tolua_property__is_set bool enabled;
+    tolua_property__is_set bool editable;
     tolua_property__is_set bool selected;
     tolua_property__is_set bool visible;
     tolua_property__is_set bool hovering;