|
|
@@ -1016,52 +1016,18 @@ namespace BansheeEngine
|
|
|
if(findElementUnderPointer(event.screenPos, buttonStates, event.shift, event.control, event.alt))
|
|
|
event.markAsUsed();
|
|
|
|
|
|
- mMouseEvent = GUIMouseEvent(buttonStates, event.shift, event.control, event.alt);
|
|
|
-
|
|
|
- GUIMouseButton guiButton = buttonToGUIButton(event.button);
|
|
|
-
|
|
|
- // We only check for mouse down if mouse isn't already being held down, and we are hovering over an element
|
|
|
- if(mActiveElements.size() == 0)
|
|
|
- {
|
|
|
- mNewActiveElements.clear();
|
|
|
- for(auto& elementInfo : mElementsUnderPointer)
|
|
|
- {
|
|
|
- Vector2I localPos = getWidgetRelativePos(elementInfo.widget, event.screenPos);
|
|
|
- mMouseEvent.setMouseDownData(localPos, guiButton);
|
|
|
-
|
|
|
- bool processed = sendMouseEvent(elementInfo.element, mMouseEvent);
|
|
|
-
|
|
|
- if(guiButton == GUIMouseButton::Left)
|
|
|
- {
|
|
|
- mDragState = DragState::HeldWithoutDrag;
|
|
|
- mLastPointerClickPos = event.screenPos;
|
|
|
- }
|
|
|
-
|
|
|
- mNewActiveElements.push_back(ElementInfo(elementInfo.element, elementInfo.widget));
|
|
|
- mActiveMouseButton = guiButton;
|
|
|
-
|
|
|
- if(processed)
|
|
|
- {
|
|
|
- event.markAsUsed();
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- mActiveElements.swap(mNewActiveElements);
|
|
|
- }
|
|
|
-
|
|
|
+ // Determine elements that gained focus
|
|
|
mNewElementsInFocus.clear();
|
|
|
+
|
|
|
mCommandEvent = GUICommandEvent();
|
|
|
-
|
|
|
- // Determine elements that gained focus
|
|
|
mCommandEvent.setType(GUICommandEventType::FocusGained);
|
|
|
|
|
|
- for(auto& elementInfo : mElementsUnderPointer)
|
|
|
+ for (auto& elementInfo : mElementsUnderPointer)
|
|
|
{
|
|
|
- auto iterFind = std::find_if(begin(mElementsInFocus), end(mElementsInFocus),
|
|
|
- [=] (const ElementFocusInfo& x) { return x.element == elementInfo.element; });
|
|
|
+ auto iterFind = std::find_if(begin(mElementsInFocus), end(mElementsInFocus),
|
|
|
+ [=](const ElementFocusInfo& x) { return x.element == elementInfo.element; });
|
|
|
|
|
|
- if(iterFind == mElementsInFocus.end())
|
|
|
+ if (iterFind == mElementsInFocus.end())
|
|
|
{
|
|
|
bool processed = sendCommandEvent(elementInfo.element, mCommandEvent);
|
|
|
mNewElementsInFocus.push_back(ElementFocusInfo(elementInfo.element, elementInfo.widget, processed));
|
|
|
@@ -1079,14 +1045,17 @@ namespace BansheeEngine
|
|
|
}
|
|
|
|
|
|
// Determine elements that lost focus
|
|
|
+ // Note: Focus loss must trigger before mouse press because things like input boxes often only confirm changes
|
|
|
+ // made to them when focus is lost. So if the user is confirming some input via a press of the button focus loss
|
|
|
+ // must trigger on the input box first to make sure its contents get saved.
|
|
|
mCommandEvent.setType(GUICommandEventType::FocusLost);
|
|
|
|
|
|
- for(auto& elementInfo : mElementsInFocus)
|
|
|
+ for (auto& elementInfo : mElementsInFocus)
|
|
|
{
|
|
|
- auto iterFind = std::find_if(begin(mNewElementsInFocus), end(mNewElementsInFocus),
|
|
|
- [=] (const ElementFocusInfo& x) { return x.element == elementInfo.element; });
|
|
|
+ auto iterFind = std::find_if(begin(mNewElementsInFocus), end(mNewElementsInFocus),
|
|
|
+ [=](const ElementFocusInfo& x) { return x.element == elementInfo.element; });
|
|
|
|
|
|
- if(iterFind == mNewElementsInFocus.end())
|
|
|
+ if (iterFind == mNewElementsInFocus.end())
|
|
|
{
|
|
|
sendCommandEvent(elementInfo.element, mCommandEvent);
|
|
|
}
|
|
|
@@ -1094,6 +1063,40 @@ namespace BansheeEngine
|
|
|
|
|
|
mElementsInFocus.swap(mNewElementsInFocus);
|
|
|
|
|
|
+ // Send mouse press event
|
|
|
+ mMouseEvent = GUIMouseEvent(buttonStates, event.shift, event.control, event.alt);
|
|
|
+ GUIMouseButton guiButton = buttonToGUIButton(event.button);
|
|
|
+
|
|
|
+ // We only check for mouse down if mouse isn't already being held down, and we are hovering over an element
|
|
|
+ if(mActiveElements.size() == 0)
|
|
|
+ {
|
|
|
+ mNewActiveElements.clear();
|
|
|
+ for(auto& elementInfo : mElementsUnderPointer)
|
|
|
+ {
|
|
|
+ Vector2I localPos = getWidgetRelativePos(elementInfo.widget, event.screenPos);
|
|
|
+ mMouseEvent.setMouseDownData(localPos, guiButton);
|
|
|
+
|
|
|
+ bool processed = sendMouseEvent(elementInfo.element, mMouseEvent);
|
|
|
+
|
|
|
+ if(guiButton == GUIMouseButton::Left)
|
|
|
+ {
|
|
|
+ mDragState = DragState::HeldWithoutDrag;
|
|
|
+ mLastPointerClickPos = event.screenPos;
|
|
|
+ }
|
|
|
+
|
|
|
+ mNewActiveElements.push_back(ElementInfo(elementInfo.element, elementInfo.widget));
|
|
|
+ mActiveMouseButton = guiButton;
|
|
|
+
|
|
|
+ if(processed)
|
|
|
+ {
|
|
|
+ event.markAsUsed();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ mActiveElements.swap(mNewActiveElements);
|
|
|
+ }
|
|
|
+
|
|
|
// If right click try to open context menu
|
|
|
if(buttonStates[2] == true)
|
|
|
{
|