Add UI ctrl + backspace support
- Added UiModule::Editable and VarTextEditable ctrl + backspace support
This commit is contained in:
parent
b7879d71eb
commit
698c4f4327
@ -202,15 +202,30 @@ namespace UiModule {
|
|||||||
event.Cancel();
|
event.Cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeleteLastWord() {
|
||||||
|
bool foundNonSpace = false;
|
||||||
|
while (!m_textBuffer.empty()) {
|
||||||
|
if (m_textBuffer.back() == L' ') {
|
||||||
|
if (foundNonSpace) break;
|
||||||
|
}
|
||||||
|
else foundNonSpace = true;
|
||||||
|
m_textBuffer.pop_back();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void OnKeyDownRepeat(KeyDownRepeatEvent& event) {
|
void OnKeyDownRepeat(KeyDownRepeatEvent& event) {
|
||||||
if (!m_active) return;
|
if (!m_active) return;
|
||||||
|
|
||||||
Game::KeyCode keyCode = event.GetKeyCode();
|
Game::KeyCode keyCode = event.GetKeyCode();
|
||||||
bool isShiftPressed = event.IsShiftPressed();
|
bool isShiftPressed = event.IsShiftPressed();
|
||||||
|
bool isCtrlPressed = event.IsCtrlPressed();
|
||||||
bool isCapsLockOn = event.IsCapsLockOn();
|
bool isCapsLockOn = event.IsCapsLockOn();
|
||||||
|
|
||||||
if (keyCode == Game::KeyCode::DIK_BACK) {
|
if (keyCode == Game::KeyCode::DIK_BACK) {
|
||||||
if (!m_textBuffer.empty()) {
|
if (isCtrlPressed) {
|
||||||
|
DeleteLastWord();
|
||||||
|
}
|
||||||
|
else if (!m_textBuffer.empty()) {
|
||||||
m_textBuffer.pop_back();
|
m_textBuffer.pop_back();
|
||||||
}
|
}
|
||||||
UpdateText();
|
UpdateText();
|
||||||
|
|||||||
@ -242,15 +242,30 @@ namespace UiModule {
|
|||||||
event.Cancel();
|
event.Cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeleteLastWord() {
|
||||||
|
bool foundNonSpace = false;
|
||||||
|
while (!m_textBuffer.empty()) {
|
||||||
|
if (m_textBuffer.back() == L' ') {
|
||||||
|
if (foundNonSpace) break;
|
||||||
|
}
|
||||||
|
else foundNonSpace = true;
|
||||||
|
m_textBuffer.pop_back();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void OnKeyDownRepeat(KeyDownRepeatEvent& event) {
|
void OnKeyDownRepeat(KeyDownRepeatEvent& event) {
|
||||||
if (!m_active) return;
|
if (!m_active) return;
|
||||||
|
|
||||||
Game::KeyCode keyCode = event.GetKeyCode();
|
Game::KeyCode keyCode = event.GetKeyCode();
|
||||||
bool isShiftPressed = event.IsShiftPressed();
|
bool isShiftPressed = event.IsShiftPressed();
|
||||||
|
bool isCtrlPressed = event.IsCtrlPressed();
|
||||||
bool isCapsLockOn = event.IsCapsLockOn();
|
bool isCapsLockOn = event.IsCapsLockOn();
|
||||||
|
|
||||||
if (keyCode == Game::KeyCode::DIK_BACK) {
|
if (keyCode == Game::KeyCode::DIK_BACK) {
|
||||||
if (!m_textBuffer.empty()) {
|
if (isCtrlPressed) {
|
||||||
|
DeleteLastWord();
|
||||||
|
}
|
||||||
|
else if (!m_textBuffer.empty()) {
|
||||||
m_textBuffer.pop_back();
|
m_textBuffer.pop_back();
|
||||||
}
|
}
|
||||||
UpdateText();
|
UpdateText();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user