void InputManager::_frameEntered(float _frame) { if ( mHoldKey == KC_UNASSIGNED) return; if ( false == isFocusKey() ) { mHoldKey = KC_UNASSIGNED; //mFirstPressKey = true; //mTimerKey = 0.0f; return; } mTimerKey += _frame; if (mFirstPressKey) { if (mTimerKey > INPUT_DELAY_FIRST_KEY) { mFirstPressKey = false; mTimerKey = 0.0f; } } else { if (mTimerKey > INPUT_INTERVAL_KEY) { mTimerKey -= INPUT_INTERVAL_KEY; mWidgetKeyFocus->_onKeyButtonPressed(mHoldKey, getKeyChar(mHoldKey)); // focus can be dropped in _onKeyButtonPressed if ( isFocusKey() ) mWidgetKeyFocus->_onKeyButtonReleased(mHoldKey); } } }
bool InputManager::injectKeyPress(KeyCode _key) { // проверка на переключение языков detectLangShift(_key, true); // запоминаем клавишу storeKey(_key); bool wasFocusKey = isFocusKey(); //Pass keystrokes to the current active text widget if (isFocusKey()) { Char ch; /*if (mUseOISKeyLayout) { ch = _arg.text; if (std::find (mCurrentLanguage->second.begin(), mCurrentLanguage->second.end(), ch) == mCurrentLanguage->second.end()) ch = 0; } else {*/ ch = getKeyChar(_key); //} mWidgetKeyFocus->_onKeyButtonPressed(_key, ch); } return wasFocusKey; }
bool InputManager::injectKeyRelease(KeyCode _key) { // проверка на переключение языков detectLangShift(_key, false); // сбрасываем клавишу resetKey(_key); bool wasFocusKey = isFocusKey(); if (isFocusKey()) mWidgetKeyFocus->_onKeyButtonReleased(_key); return wasFocusKey; }
void InputManager::setKeyFocusWidget(WidgetPtr _widget) { // ищем рутовый фокус WidgetPtr root = _widget; if (root != null) { while (root->_getOwner() != null) root = root->_getOwner(); } // если рутовый фокус поменялся, то оповещаем if (mWidgetRootKeyFocus != root) { if (mWidgetRootKeyFocus != null) mWidgetRootKeyFocus->_onKeyChangeRootFocus(false); if (root != null) root->_onKeyChangeRootFocus(true); mWidgetRootKeyFocus = root; } // а вот тут уже проверяем обыкновенный фокус if (_widget == mWidgetKeyFocus) return; if (isFocusKey()) mWidgetKeyFocus->_onKeyLostFocus(_widget); if (_widget != null) { if (_widget->isNeedKeyFocus()) { _widget->_onKeySetFocus(mWidgetKeyFocus); mWidgetKeyFocus = _widget; return; } } mWidgetKeyFocus = null; }
bool InputManager::injectKeyPress(KeyCode _key, Char _text) { // проверка на переключение языков firstEncoding(_key, true); // запоминаем клавишу storeKey(_key, _text); bool wasFocusKey = isFocusKey(); //Pass keystrokes to the current active text widget if (isFocusKey()) { mWidgetKeyFocus->_riseKeyButtonPressed(_key, _text); } return wasFocusKey; }
bool InputManager::injectKeyRelease(KeyCode _key) { if(eventHotKeyReleasedPreprocess) { if(eventHotKeyReleasedPreprocess(_key)) return false; } // проверка на переключение языков firstEncoding(_key, false); // сбрасываем клавишу resetKey(); bool wasFocusKey = isFocusKey(); if (isFocusKey()) mWidgetKeyFocus->_riseKeyButtonReleased(_key); return wasFocusKey; }
void InputManager::frameEntered(float _frame) { mTimerDoubleClick += _frame; if ( mHoldKey == KeyCode::None) return; if ( !isFocusKey() ) { mHoldKey = KeyCode::None; mHoldChar = 0; return; } mTimerKey += _frame; if (mFirstPressKey) { if (mTimerKey > INPUT_DELAY_FIRST_KEY) { mFirstPressKey = false; mTimerKey = 0.0f; } } else { if (mTimerKey > INPUT_INTERVAL_KEY) { while (mTimerKey > INPUT_INTERVAL_KEY) mTimerKey -= INPUT_INTERVAL_KEY; mWidgetKeyFocus->_riseKeyButtonPressed(mHoldKey, mHoldChar); // focus can be dropped in onKeyButtonPressed if (isFocusKey()) mWidgetKeyFocus->_riseKeyButtonReleased(mHoldKey); } } }
void InputManager::storeKey(KeyCode _key) { mHoldKey = KC_UNASSIGNED; if ( false == isFocusKey() ) return; if ( (_key == KC_LSHIFT) || (_key == KC_RSHIFT) || (_key == KC_LCONTROL) || (_key == KC_RCONTROL) || (_key == KC_LMENU) || (_key == KC_RMENU) ) return; mFirstPressKey = true; mHoldKey = _key; mTimerKey = 0.0f; }
void InputManager::storeKey(KeyCode _key, Char _text) { mHoldKey = KeyCode::None; mHoldChar = 0; if ( !isFocusKey() ) return; if ( (_key == KeyCode::LeftShift) || (_key == KeyCode::RightShift) || (_key == KeyCode::LeftControl) || (_key == KeyCode::RightControl) || (_key == KeyCode::LeftAlt) || (_key == KeyCode::RightAlt) ) return; mFirstPressKey = true; mHoldKey = _key; mHoldChar = _text; mTimerKey = 0.0f; }