// // Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. // #include using namespace tb; #include "../Core/Timer.h" #include "../Input/Input.h" #include "../Input/InputEvents.h" #include "UI.h" #include "UIEvents.h" #include "UIView.h" namespace Atomic { static MODIFIER_KEYS GetModifierKeys(int qualifiers, bool superKey) { MODIFIER_KEYS code = TB_MODIFIER_NONE; if (qualifiers & QUAL_ALT) code |= TB_ALT; if (qualifiers & QUAL_CTRL) code |= TB_CTRL; if (qualifiers & QUAL_SHIFT) code |= TB_SHIFT; if (superKey) code |= TB_SUPER; return code; } // @return Return the upper case of a ascii charcter. Only for shortcut handling. static int toupr_ascii(int ascii) { if (ascii >= 'a' && ascii <= 'z') return ascii + 'A' - 'a'; return ascii; } bool UIView::FilterDefaultInput(bool keyEvent) const { if (!GetInputEnabled()) return true; if (ui_.Null() || ui_->GetFocusedView() != this) return true; if (ui_->inputDisabled_ || ui_->consoleVisible_) return true; if (renderTexture_ && !keyEvent) return true; if (!keyEvent && !GetMouseEnabled()) return true; if (keyEvent && !GetKeyboardEnabled() || ui_->keyboardDisabled_) return true; return false; } void UIView::HandleMouseButtonDown(StringHash eventType, VariantMap& eventData) { if (FilterDefaultInput()) return; using namespace MouseButtonDown; unsigned button = eventData[P_BUTTON].GetUInt(); IntVector2 pos; pos = GetSubsystem()->GetMousePosition(); Input* input = GetSubsystem(); int qualifiers = input->GetQualifiers(); #ifdef ATOMIC_PLATFORM_WINDOWS bool superdown = input->GetKeyDown(KEY_LCTRL) || input->GetKeyDown(KEY_RCTRL); #else bool superdown = input->GetKeyDown(KEY_LGUI) || input->GetKeyDown(KEY_RGUI); #endif MODIFIER_KEYS mod = GetModifierKeys(qualifiers, superdown); static double last_time = 0; static int counter = 1; Time* t = GetSubsystem