Browse Source

Split UIElement::OnClick() to OnClickBegin() & OnClickEnd(), added global UIMouseClickEnd event, cleaned up Button & CheckBox click handling, based on Chris Friesen's work.
Fixed bug in FileSelector which would cause potentially any keypress to select a file.
Added missing icon for View3D UI element.

Lasse Öörni 12 years ago
parent
commit
1eae2e13ab

+ 4 - 0
Bin/Data/UI/EditorIcons.xml

@@ -171,6 +171,10 @@
         <attribute name="Texture" value="Texture2D;Textures/EditorIcons.png" />
         <attribute name="Texture" value="Texture2D;Textures/EditorIcons.png" />
         <attribute name="Image Rect" value="144 32 158 46" />
         <attribute name="Image Rect" value="144 32 158 46" />
     </element>
     </element>
+    <element type="View3D">
+        <attribute name="Texture" value="Texture2D;Textures/EditorIcons.png" />
+        <attribute name="Image Rect" value="144 32 158 46" />
+    </element>
     <element type="ScrollBar">
     <element type="ScrollBar">
         <attribute name="Texture" value="Texture2D;Textures/EditorIcons.png" />
         <attribute name="Texture" value="Texture2D;Textures/EditorIcons.png" />
         <attribute name="Image Rect" value="128 32 142 46" />
         <attribute name="Image Rect" value="128 32 142 46" />

+ 12 - 13
Source/Engine/UI/Button.cpp

@@ -94,34 +94,33 @@ void Button::GetBatches(PODVector<UIBatch>& batches, PODVector<float>& vertexDat
     BorderImage::GetBatches(batches, vertexData, currentScissor, offset);
     BorderImage::GetBatches(batches, vertexData, currentScissor, offset);
 }
 }
 
 
-void Button::OnHover(const IntVector2& position, const IntVector2& screenPosition, int buttons, int qualifiers, Cursor* cursor)
+void Button::OnClickBegin(const IntVector2& position, const IntVector2& screenPosition, int button, int buttons, int qualifiers, Cursor* cursor)
 {
 {
-    BorderImage::OnHover(position, screenPosition, buttons, qualifiers, cursor);
-    if (pressed_ && !(buttons & MOUSEB_LEFT))
+    if (button == MOUSEB_LEFT)
     {
     {
-        SetPressed(false);
+        SetPressed(true);
+        repeatTimer_ = repeatDelay_;
+        hovering_ = true;
 
 
-        using namespace Released;
+        using namespace Pressed;
 
 
         VariantMap eventData;
         VariantMap eventData;
         eventData[P_ELEMENT] = (void*)this;
         eventData[P_ELEMENT] = (void*)this;
-        SendEvent(E_RELEASED, eventData);
+        SendEvent(E_PRESSED, eventData);
     }
     }
 }
 }
 
 
-void Button::OnClick(const IntVector2& position, const IntVector2& screenPosition, int buttons, int qualifiers, Cursor* cursor)
+void Button::OnClickEnd(const IntVector2& position, const IntVector2& screenPosition, int button, int buttons, int qualifiers, Cursor* cursor, UIElement* beginElement)
 {
 {
-    if (buttons & MOUSEB_LEFT)
+    if (pressed_ && button == MOUSEB_LEFT)
     {
     {
-        SetPressed(true);
-        repeatTimer_ = repeatDelay_;
-        hovering_ = true;
+        SetPressed(false);
 
 
-        using namespace Pressed;
+        using namespace Released;
 
 
         VariantMap eventData;
         VariantMap eventData;
         eventData[P_ELEMENT] = (void*)this;
         eventData[P_ELEMENT] = (void*)this;
-        SendEvent(E_PRESSED, eventData);
+        SendEvent(E_RELEASED, eventData);
     }
     }
 }
 }
 
 

+ 4 - 4
Source/Engine/UI/Button.h

@@ -44,10 +44,10 @@ public:
     virtual void Update(float timeStep);
     virtual void Update(float timeStep);
     /// Return UI rendering batches.
     /// Return UI rendering batches.
     virtual void GetBatches(PODVector<UIBatch>& batches, PODVector<float>& vertexData, const IntRect& currentScissor);
     virtual void GetBatches(PODVector<UIBatch>& batches, PODVector<float>& vertexData, const IntRect& currentScissor);
-    /// React to mouse hover.
-    virtual void OnHover(const IntVector2& position, const IntVector2& screenPosition, int buttons, int qualifiers, Cursor* cursor);
-    /// React to mouse click.
-    virtual void OnClick(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);
+    /// React to mouse click end.
+    virtual void OnClickEnd(const IntVector2& position, const IntVector2& screenPosition, int button, int buttons, int qualifiers, Cursor* cursor, UIElement* beginElement);
     /// React to mouse drag motion.
     /// 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);
 
 

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

@@ -66,9 +66,9 @@ void CheckBox::GetBatches(PODVector<UIBatch>& batches, PODVector<float>& vertexD
     BorderImage::GetBatches(batches, vertexData, currentScissor, offset);
     BorderImage::GetBatches(batches, vertexData, currentScissor, offset);
 }
 }
 
 
-void CheckBox::OnClick(const IntVector2& position, const IntVector2& screenPosition, int buttons, int qualifiers, Cursor* cursor)
+void CheckBox::OnClickEnd(const IntVector2& position, const IntVector2& screenPosition, int button, int buttons, int qualifiers, Cursor* cursor, UIElement* beginElement)
 {
 {
-    if (buttons & MOUSEB_LEFT)
+    if (button == MOUSEB_LEFT && beginElement == this)
         SetChecked(!checked_);
         SetChecked(!checked_);
 }
 }
 
 

+ 2 - 2
Source/Engine/UI/CheckBox.h

@@ -42,8 +42,8 @@ public:
     
     
     /// Return UI rendering batches.
     /// Return UI rendering batches.
     virtual void GetBatches(PODVector<UIBatch>& batches, PODVector<float>& vertexData, const IntRect& currentScissor);
     virtual void GetBatches(PODVector<UIBatch>& batches, PODVector<float>& vertexData, const IntRect& currentScissor);
-    /// React to mouse click.
-    virtual void OnClick(const IntVector2& position, const IntVector2& screenPosition, 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);
     
     
     /// Set checked state.
     /// Set checked state.
     void SetChecked(bool enable);
     void SetChecked(bool enable);

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

@@ -451,7 +451,7 @@ void FileSelector::HandleFileListKey(StringHash eventType, VariantMap& eventData
     using namespace UnhandledKey;
     using namespace UnhandledKey;
 
 
     int key = eventData[P_KEY].GetInt();
     int key = eventData[P_KEY].GetInt();
-    if (key == KEY_RETURN || key == KEY_RETURN2 || KEY_KP_ENTER)
+    if (key == KEY_RETURN || key == KEY_RETURN2 || key == KEY_KP_ENTER)
     {
     {
         bool entered = EnterFile();
         bool entered = EnterFile();
         // When a key is used to enter a directory, select the first file if no selection
         // When a key is used to enter a directory, select the first file if no selection

+ 5 - 4
Source/Engine/UI/LineEdit.cpp

@@ -112,9 +112,9 @@ void LineEdit::Update(float timeStep)
     cursor_->SetVisible(cursorVisible);
     cursor_->SetVisible(cursorVisible);
 }
 }
 
 
-void LineEdit::OnClick(const IntVector2& position, const IntVector2& screenPosition, int buttons, int qualifiers, Cursor* cursor)
+void LineEdit::OnClickBegin(const IntVector2& position, const IntVector2& screenPosition, int button, int buttons, int qualifiers, Cursor* cursor)
 {
 {
-    if (buttons & MOUSEB_LEFT && cursorMovable_)
+    if (button == MOUSEB_LEFT && cursorMovable_)
     {
     {
         unsigned pos = GetCharIndex(position);
         unsigned pos = GetCharIndex(position);
         if (pos != M_MAX_UNSIGNED)
         if (pos != M_MAX_UNSIGNED)
@@ -125,9 +125,10 @@ void LineEdit::OnClick(const IntVector2& position, const IntVector2& screenPosit
     }
     }
 }
 }
 
 
-void LineEdit::OnDoubleClick(const IntVector2& position, const IntVector2& screenPosition, int buttons, int qualifiers, Cursor* cursor)
+void LineEdit::OnDoubleClick(const IntVector2& position, const IntVector2& screenPosition, int button, int buttons, int qualifiers, Cursor* cursor)
 {
 {
-    text_->SetSelection(0);
+    if (button == MOUSEB_LEFT)
+        text_->SetSelection(0);
 }
 }
 
 
 void LineEdit::OnDragBegin(const IntVector2& position, const IntVector2& screenPosition, int buttons, int qualifiers, Cursor* cursor)
 void LineEdit::OnDragBegin(const IntVector2& position, const IntVector2& screenPosition, int buttons, int qualifiers, Cursor* cursor)

+ 3 - 3
Source/Engine/UI/LineEdit.h

@@ -48,10 +48,10 @@ public:
     /// Perform UI element update.
     /// Perform UI element update.
     virtual void Update(float timeStep);
     virtual void Update(float timeStep);
 
 
-    /// React to mouse click.
-    virtual void OnClick(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);
     /// React to mouse doubleclick.
     /// React to mouse doubleclick.
-    virtual void OnDoubleClick(const IntVector2& position, const IntVector2& screenPosition, 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.
     /// 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.
     /// React to mouse drag motion.

+ 16 - 4
Source/Engine/UI/ScrollBar.cpp

@@ -284,16 +284,28 @@ void ScrollBar::HandleSliderPaged(StringHash eventType, VariantMap& eventData)
     if (eventData[P_BUTTONS].GetInt() & MOUSEB_LEFT)
     if (eventData[P_BUTTONS].GetInt() & MOUSEB_LEFT)
     {
     {
         if (eventData[P_OFFSET].GetInt() < 0)
         if (eventData[P_OFFSET].GetInt() < 0)
-            backButton_->OnClick(IntVector2::ZERO, backButton_->ElementToScreen(IntVector2::ZERO), eventData[P_BUTTONS].GetInt(), eventData[P_QUALIFIERS].GetInt(), 0);
+        {
+            backButton_->OnClickBegin(IntVector2::ZERO, backButton_->ElementToScreen(IntVector2::ZERO),
+                eventData[P_BUTTON].GetInt(), eventData[P_BUTTONS].GetInt(), eventData[P_QUALIFIERS].GetInt(), 0);
+        }
         else
         else
-            forwardButton_->OnClick(IntVector2::ZERO, backButton_->ElementToScreen(IntVector2::ZERO), eventData[P_BUTTONS].GetInt(), eventData[P_QUALIFIERS].GetInt(), 0);
+        {
+            forwardButton_->OnClickBegin(IntVector2::ZERO, backButton_->ElementToScreen(IntVector2::ZERO),
+                eventData[P_BUTTON].GetInt(), eventData[P_BUTTONS].GetInt(), eventData[P_QUALIFIERS].GetInt(), 0);
+        }
     }
     }
     else
     else
     {
     {
         if (eventData[P_OFFSET].GetInt() < 0)
         if (eventData[P_OFFSET].GetInt() < 0)
-            backButton_->OnHover(IntVector2::ZERO, backButton_->ElementToScreen(IntVector2::ZERO), eventData[P_BUTTONS].GetInt(), eventData[P_QUALIFIERS].GetInt(), 0);
+        {
+            backButton_->OnHover(IntVector2::ZERO, backButton_->ElementToScreen(IntVector2::ZERO), eventData[P_BUTTONS].GetInt(),
+                eventData[P_QUALIFIERS].GetInt(), 0);
+        }
         else
         else
-            forwardButton_->OnHover(IntVector2::ZERO, backButton_->ElementToScreen(IntVector2::ZERO), eventData[P_BUTTONS].GetInt(), eventData[P_QUALIFIERS].GetInt(), 0);
+        {
+            forwardButton_->OnHover(IntVector2::ZERO, backButton_->ElementToScreen(IntVector2::ZERO),
+                eventData[P_BUTTONS].GetInt(), eventData[P_QUALIFIERS].GetInt(), 0);
+        }
     }
     }
 }
 }
 
 

+ 5 - 5
Source/Engine/UI/Slider.cpp

@@ -96,16 +96,15 @@ void Slider::OnHover(const IntVector2& position, const IntVector2& screenPositio
 
 
     // If not hovering on the knob, send it as page event
     // If not hovering on the knob, send it as page event
     if (!hovering_)
     if (!hovering_)
-        Page(position, buttons, qualifiers);
+        Page(position, 0, buttons, qualifiers);
 }
 }
 
 
-void Slider::OnClick(const IntVector2& position, const IntVector2& screenPosition, int buttons, int qualifiers, Cursor* cursor)
+void Slider::OnClickBegin(const IntVector2& position, const IntVector2& screenPosition, int button, int buttons, int qualifiers, Cursor* cursor)
 {
 {
-    BorderImage::OnClick(position, screenPosition, buttons, qualifiers, cursor);
     selected_ = true;
     selected_ = true;
     hovering_ = knob_->IsInside(screenPosition, true);
     hovering_ = knob_->IsInside(screenPosition, true);
     if (!hovering_)
     if (!hovering_)
-        Page(position, buttons, qualifiers);
+        Page(position, button, buttons, qualifiers);
 }
 }
 
 
 void Slider::OnDragBegin(const IntVector2& position, const IntVector2& screenPosition, int buttons, int qualifiers, Cursor* cursor)
 void Slider::OnDragBegin(const IntVector2& position, const IntVector2& screenPosition, int buttons, int qualifiers, Cursor* cursor)
@@ -239,7 +238,7 @@ void Slider::UpdateSlider()
     }
     }
 }
 }
 
 
-void Slider::Page(const IntVector2& position, int buttons, int qualifiers)
+void Slider::Page(const IntVector2& position, int button, int buttons, int qualifiers)
 {
 {
     IntVector2 offsetXY = position - knob_->GetPosition() - knob_->GetSize() / 2;
     IntVector2 offsetXY = position - knob_->GetPosition() - knob_->GetSize() / 2;
     int offset = orientation_ == O_HORIZONTAL ? offsetXY.x_ : offsetXY.y_;
     int offset = orientation_ == O_HORIZONTAL ? offsetXY.x_ : offsetXY.y_;
@@ -255,6 +254,7 @@ void Slider::Page(const IntVector2& position, int buttons, int qualifiers)
     if (selected_ && repeatRate_ > 0.0f && repeatTimer_.GetMSec(false) >= Lerp(1000.0f / repeatRate_, 0, Abs(offset) / length))
     if (selected_ && repeatRate_ > 0.0f && repeatTimer_.GetMSec(false) >= Lerp(1000.0f / repeatRate_, 0, Abs(offset) / length))
     {
     {
         repeatTimer_.Reset();
         repeatTimer_.Reset();
+        eventData[P_BUTTON] = button;
         eventData[P_BUTTONS] = buttons;
         eventData[P_BUTTONS] = buttons;
         eventData[P_QUALIFIERS] = qualifiers;
         eventData[P_QUALIFIERS] = qualifiers;
     }
     }

+ 4 - 4
Source/Engine/UI/Slider.h

@@ -43,9 +43,9 @@ public:
     /// Perform UI element update.
     /// Perform UI element update.
     virtual void Update(float timeStep);
     virtual void Update(float timeStep);
     /// React to mouse hover.
     /// React to mouse hover.
-    virtual void OnHover(const IntVector2& position, const IntVector2& screenPosition, int buttons, int qualifiers, Cursor* cursor);
-    /// React to mouse click.
-    virtual void OnClick(const IntVector2& position, const IntVector2& screenPosition, int buttons, int qualifiers, Cursor* cursor);
+    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);
     /// React to mouse drag begin.
     /// 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.
     /// React to mouse drag motion.
@@ -83,7 +83,7 @@ protected:
     /// Update slider knob position & size.
     /// Update slider knob position & size.
     void UpdateSlider();
     void UpdateSlider();
     /// Send slider page event.
     /// Send slider page event.
-    void Page(const IntVector2& position, int buttons, int qualifiers);
+    void Page(const IntVector2& position, int button, int buttons, int qualifiers);
 
 
     /// Slider knob.
     /// Slider knob.
     SharedPtr<BorderImage> knob_;
     SharedPtr<BorderImage> knob_;

+ 21 - 6
Source/Engine/UI/UI.cpp

@@ -810,14 +810,17 @@ void UI::ProcessClickBegin(const IntVector2& cursorPos, int button, int buttons,
             }
             }
 
 
             // Handle click
             // Handle click
-            element->OnClick(element->ScreenToElement(cursorPos), cursorPos, buttons, qualifiers, cursor);
+            element->OnClickBegin(element->ScreenToElement(cursorPos), cursorPos, button, buttons, qualifiers, cursor);
             SendClickEvent(E_UIMOUSECLICK, element, cursorPos, button, buttons, qualifiers);
             SendClickEvent(E_UIMOUSECLICK, element, cursorPos, button, buttons, qualifiers);
 
 
+            // Remember element clicked on for the click end
+            clickElement_ = element;
+            
             // Fire double click event if element matches and is in time
             // Fire double click event if element matches and is in time
             if (doubleClickElement_ && element == doubleClickElement_ && clickTimer_->GetMSec(true) <
             if (doubleClickElement_ && element == doubleClickElement_ && clickTimer_->GetMSec(true) <
                 (unsigned)(doubleClickInterval_ * 1000) && lastMouseButtons_ == buttons)
                 (unsigned)(doubleClickInterval_ * 1000) && lastMouseButtons_ == buttons)
             {
             {
-                element->OnDoubleClick(element->ScreenToElement(cursorPos), cursorPos, buttons, qualifiers, cursor);
+                element->OnDoubleClick(element->ScreenToElement(cursorPos), cursorPos, button, buttons, qualifiers, cursor);
                 doubleClickElement_.Reset();
                 doubleClickElement_.Reset();
                 SendClickEvent(E_UIMOUSEDOUBLECLICK, element, cursorPos, button, buttons, qualifiers);
                 SendClickEvent(E_UIMOUSEDOUBLECLICK, element, cursorPos, button, buttons, qualifiers);
             }
             }
@@ -848,10 +851,17 @@ void UI::ProcessClickBegin(const IntVector2& cursorPos, int button, int buttons,
 
 
 void UI::ProcessClickEnd(const IntVector2& cursorPos, int button, int buttons, int qualifiers, Cursor* cursor, bool cursorVisible)
 void UI::ProcessClickEnd(const IntVector2& cursorPos, int button, int buttons, int qualifiers, Cursor* cursor, bool cursorVisible)
 {
 {
-    WeakPtr<UIElement> element(GetElementAt(cursorPos));
-
-    if (cursorVisible || dragElement_)
+    if (cursorVisible)
     {
     {
+        WeakPtr<UIElement> element(GetElementAt(cursorPos));
+
+        // Handle end of click
+        if (element)
+            element->OnClickEnd(element->ScreenToElement(cursorPos), cursorPos, button, buttons, qualifiers, cursor, clickElement_);
+        
+        SendClickEvent(E_UIMOUSECLICKEND, element, cursorPos, button, buttons, qualifiers);
+        
+        // Handle end of drag
         if (dragElement_ && !buttons)
         if (dragElement_ && !buttons)
         {
         {
             if (dragElement_->IsEnabled() && dragElement_->IsVisible())
             if (dragElement_->IsEnabled() && dragElement_->IsVisible())
@@ -859,7 +869,6 @@ void UI::ProcessClickEnd(const IntVector2& cursorPos, int button, int buttons, i
                 dragElement_->OnDragEnd(dragElement_->ScreenToElement(cursorPos), cursorPos, cursor);
                 dragElement_->OnDragEnd(dragElement_->ScreenToElement(cursorPos), cursorPos, cursor);
                 SendDragEvent(E_DRAGEND, dragElement_, cursorPos);
                 SendDragEvent(E_DRAGEND, dragElement_, cursorPos);
 
 
-                // Drag and drop finish
                 bool dragSource = dragElement_ && (dragElement_->GetDragDropMode() & DD_SOURCE) != 0;
                 bool dragSource = dragElement_ && (dragElement_->GetDragDropMode() & DD_SOURCE) != 0;
                 if (dragSource)
                 if (dragSource)
                 {
                 {
@@ -887,6 +896,8 @@ void UI::ProcessClickEnd(const IntVector2& cursorPos, int button, int buttons, i
 
 
             dragElement_.Reset();
             dragElement_.Reset();
         }
         }
+        
+        clickElement_.Reset();
     }
     }
 }
 }
 
 
@@ -937,6 +948,10 @@ void UI::SendClickEvent(StringHash eventType, UIElement* element, const IntVecto
     eventData[UIMouseClick::P_BUTTONS] = buttons;
     eventData[UIMouseClick::P_BUTTONS] = buttons;
     eventData[UIMouseClick::P_QUALIFIERS] = qualifiers;
     eventData[UIMouseClick::P_QUALIFIERS] = qualifiers;
     
     
+    // For click end events, send also the element the click began on
+    if (eventType == E_UIMOUSECLICKEND)
+        eventData[UIMouseClickEnd::P_BEGINELEMENT] = clickElement_;
+    
     SendEvent(eventType, eventData);
     SendEvent(eventType, eventData);
 }
 }
 
 

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

@@ -215,6 +215,8 @@ private:
     unsigned nonModalBatchSize_;
     unsigned nonModalBatchSize_;
     /// Timer used to trigger double click.
     /// Timer used to trigger double click.
     Timer* clickTimer_;
     Timer* clickTimer_;
+    /// UI element last clicked for tracking click end.
+    WeakPtr<UIElement> clickElement_;
     /// UI element last clicked for tracking double clicks.
     /// UI element last clicked for tracking double clicks.
     WeakPtr<UIElement> doubleClickElement_;
     WeakPtr<UIElement> doubleClickElement_;
     /// Last mouse button pressed.
     /// Last mouse button pressed.

+ 6 - 2
Source/Engine/UI/UIElement.cpp

@@ -485,11 +485,15 @@ void UIElement::OnHover(const IntVector2& position, const IntVector2& screenPosi
     hovering_ = true;
     hovering_ = true;
 }
 }
 
 
-void UIElement::OnClick(const IntVector2& position, const IntVector2& screenPosition, int buttons, int qualifiers, Cursor* cursor)
+void UIElement::OnClickBegin(const IntVector2& position, const IntVector2& screenPosition, int button, int buttons, int qualifiers, Cursor* cursor)
 {
 {
 }
 }
 
 
-void UIElement::OnDoubleClick(const IntVector2& position, const IntVector2& screenPosition, 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)
 {
 {
 }
 }
 
 

+ 5 - 3
Source/Engine/UI/UIElement.h

@@ -146,10 +146,12 @@ public:
     virtual void GetDebugDrawBatches(PODVector<UIBatch>& batches, PODVector<float>& vertexData, const IntRect& currentScissor);
     virtual void GetDebugDrawBatches(PODVector<UIBatch>& batches, PODVector<float>& vertexData, const IntRect& currentScissor);
     /// React to mouse hover.
     /// React to mouse hover.
     virtual void OnHover(const IntVector2& position, const IntVector2& screenPosition, int buttons, int qualifiers, Cursor* cursor);
     virtual void OnHover(const IntVector2& position, const IntVector2& screenPosition, int buttons, int qualifiers, Cursor* cursor);
-    /// React to mouse click.
-    virtual void OnClick(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);
+    /// React to mouse click end.
+    virtual void OnClickEnd(const IntVector2& position, const IntVector2& screenPosition, int button, int buttons, int qualifiers, Cursor* cursor, UIElement* beginElement);
     /// React to double mouse click.
     /// React to double mouse click.
-    virtual void OnDoubleClick(const IntVector2& position, const IntVector2& screenPosition, 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.
     /// 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.
     /// React to mouse drag motion.

+ 13 - 0
Source/Engine/UI/UIEvents.h

@@ -38,6 +38,18 @@ EVENT(E_UIMOUSECLICK, UIMouseClick)
     PARAM(P_QUALIFIERS, Qualifiers);        // int
     PARAM(P_QUALIFIERS, Qualifiers);        // int
 }
 }
 
 
+/// Mouse click end in the UI.
+EVENT(E_UIMOUSECLICKEND, UIMouseClickEnd)
+{
+    PARAM(P_ELEMENT, Element);              // UIElement pointer
+    PARAM(P_BEGINELEMENT, BeginElement);    // UIElement pointer
+    PARAM(P_X, X);                          // int
+    PARAM(P_Y, Y);                          // int
+    PARAM(P_BUTTON, Button);                // int
+    PARAM(P_BUTTONS, Buttons);              // int
+    PARAM(P_QUALIFIERS, Qualifiers);        // int
+}
+
 /// Mouse double click in the UI.
 /// Mouse double click in the UI.
 EVENT(E_UIMOUSEDOUBLECLICK, UIMouseDoubleClick)
 EVENT(E_UIMOUSEDOUBLECLICK, UIMouseDoubleClick)
 {
 {
@@ -150,6 +162,7 @@ EVENT(E_SLIDERPAGED, SliderPaged)
 {
 {
     PARAM(P_ELEMENT, Element);              // UIElement pointer
     PARAM(P_ELEMENT, Element);              // UIElement pointer
     PARAM(P_OFFSET, Offset);                // int
     PARAM(P_OFFSET, Offset);                // int
+    PARAM(P_BUTTON, Button);                // int
     PARAM(P_BUTTONS, Buttons);              // int
     PARAM(P_BUTTONS, Buttons);              // int
     PARAM(P_QUALIFIERS, Qualifiers);        // int
     PARAM(P_QUALIFIERS, Qualifiers);        // int
 }
 }