bool CGUIDialogKeyboardGeneric::OnMessage(CGUIMessage& message) { CGUIDialog::OnMessage(message); switch ( message.GetMessage() ) { case GUI_MSG_CLICKED: { int iControl = message.GetSenderId(); switch (iControl) { case CTL_BUTTON_DONE: OnOK(); break; case CTL_BUTTON_CANCEL: Close(); break; case CTL_BUTTON_SHIFT: OnShift(); break; case CTL_BUTTON_CAPS: if (m_keyType == LOWER) m_keyType = CAPS; else if (m_keyType == CAPS) m_keyType = LOWER; UpdateButtons(); break; case CTL_BUTTON_SYMBOLS: OnSymbols(); break; case CTL_BUTTON_LEFT: MoveCursor( -1); break; case CTL_BUTTON_RIGHT: MoveCursor(1); break; case CTL_BUTTON_IP_ADDRESS: OnIPAddress(); break; default: m_lastRemoteKeyClicked = 0; OnClickButton(iControl); break; } } break; case GUI_MSG_SET_TEXT: SetText(message.GetLabel()); // close the dialog if requested if (message.GetParam1() > 0) OnOK(); break; } return true; }
bool CGUIDialogKeyboardGeneric::OnAction(const CAction &action) { bool handled = true; if (action.GetID() == ACTION_ENTER) OnOK(); else if (action.GetID() == ACTION_SHIFT) OnShift(); else if (action.GetID() == ACTION_SYMBOLS) OnSymbols(); // don't handle move left/right and select in the edit control else if (action.GetID() == ACTION_MOVE_LEFT || action.GetID() == ACTION_MOVE_RIGHT || action.GetID() == ACTION_SELECT_ITEM) handled = false; else { handled = false; // send action to edit control CGUIControl *edit = GetControl(CTL_EDIT); if (edit) handled = edit->OnAction(action); } if (!handled) // unhandled by us - let's see if the baseclass wants it handled = CGUIDialog::OnAction(action); return handled; }
bool CGUIDialogKeyboard::OnMessage(CGUIMessage& message) { CGUIDialog::OnMessage(message); switch ( message.GetMessage() ) { case GUI_MSG_CLICKED: { int iControl = message.GetSenderId(); switch (iControl) { case CTL_BUTTON_DONE: { OnOK(); break; } case CTL_BUTTON_CANCEL: Close(); break; case CTL_BUTTON_SHIFT: OnShift(); break; case CTL_BUTTON_CAPS: if (m_keyType == LOWER) m_keyType = CAPS; else if (m_keyType == CAPS) m_keyType = LOWER; UpdateButtons(); break; case CTL_BUTTON_SYMBOLS: OnSymbols(); break; case CTL_BUTTON_LEFT: { MoveCursor( -1); } break; case CTL_BUTTON_RIGHT: { MoveCursor(1); } break; case CTL_BUTTON_IP_ADDRESS: { OnIPAddress(); } default: m_lastRemoteKeyClicked = 0; OnClickButton(iControl); break; } } break; } return true; }
char CGUIDialogKeyboardGeneric::GetCharacter(int iButton) { // First the numbers if (iButton >= 48 && iButton <= 57) { if (m_keyType == SYMBOLS) { OnSymbols(); return symbol_map[iButton -48]; } else return (char)iButton; } else if (iButton == 32) // space return (char)iButton; else if (iButton >= 65 && iButton < 91) { if (m_keyType == SYMBOLS) { // symbol OnSymbols(); return symbol_map[iButton - 65 + 10]; } if ((m_keyType == CAPS && m_bShift) || (m_keyType == LOWER && !m_bShift)) { // make lower case iButton += 32; } if (m_bShift) { // turn off the shift key OnShift(); } return (char) iButton; } else { // check for symbols for (unsigned int i = 0; i < NUM_SYMBOLS; i++) if (iButton == symbolButtons[i]) return (char)iButton; } return 0; }
bool CGUIDialogKeyboardGeneric::OnAction(const CAction &action) { bool handled = true; if (action.GetID() == ACTION_ENTER || (m_isKeyboardNavigationMode && action.GetID() == ACTION_SELECT_ITEM)) OnOK(); else if (action.GetID() == ACTION_SHIFT) OnShift(); else if (action.GetID() == ACTION_SYMBOLS) OnSymbols(); // don't handle move left/right and select in the edit control else if (!m_isKeyboardNavigationMode && (action.GetID() == ACTION_MOVE_LEFT || action.GetID() == ACTION_MOVE_RIGHT || action.GetID() == ACTION_SELECT_ITEM)) handled = false; else { handled = false; // send action to edit control CGUIControl *edit = GetControl(CTL_EDIT); if (edit) handled = edit->OnAction(action); if (!handled && action.GetID() >= KEY_VKEY && action.GetID() < KEY_ASCII) { BYTE b = action.GetID() & 0xFF; if (b == XBMCVK_TAB) { // Toggle left/right key mode m_isKeyboardNavigationMode = !m_isKeyboardNavigationMode; if (m_isKeyboardNavigationMode) { m_previouslyFocusedButton = GetFocusedControlID(); SET_CONTROL_FOCUS(edit->GetID(), 0); } else SET_CONTROL_FOCUS(m_previouslyFocusedButton, 0); handled = true; } } } if (!handled) // unhandled by us - let's see if the baseclass wants it handled = CGUIDialog::OnAction(action); return handled; }
bool CGUIDialogKeyboardGeneric::OnAction(const CAction &action) { bool handled(true); if (action.GetID() == ACTION_BACKSPACE) { Backspace(); } else if (action.GetID() == ACTION_ENTER) { OnOK(); } else if (action.GetID() == ACTION_CURSOR_LEFT) { MoveCursor( -1); } else if (action.GetID() == ACTION_CURSOR_RIGHT) { MoveCursor(1); } else if (action.GetID() == ACTION_SHIFT) { OnShift(); } else if (action.GetID() == ACTION_SYMBOLS) { OnSymbols(); } else if (action.GetID() >= KEY_ASCII) { // send action to the edit control CGUIControl *edit = GetControl(CTL_EDIT); if (edit) edit->OnAction(action); } else // unhandled by us - let's see if the baseclass wants it handled = CGUIDialog::OnAction(action); return handled; }
bool CGUIDialogKeyboardGeneric::OnMessage(CGUIMessage& message) { switch ( message.GetMessage() ) { case GUI_MSG_CLICKED: { int iControl = message.GetSenderId(); switch (iControl) { case CTL_BUTTON_DONE: OnOK(); break; case CTL_BUTTON_CANCEL: Close(); break; case CTL_BUTTON_SHIFT: OnShift(); break; case CTL_BUTTON_CAPS: if (m_keyType == LOWER) m_keyType = CAPS; else if (m_keyType == CAPS) m_keyType = LOWER; UpdateButtons(); break; case CTL_BUTTON_LAYOUT: OnLayout(); break; case CTL_BUTTON_SYMBOLS: OnSymbols(); break; case CTL_BUTTON_LEFT: MoveCursor( -1); break; case CTL_BUTTON_RIGHT: MoveCursor(1); break; case CTL_BUTTON_IP_ADDRESS: OnIPAddress(); break; case CTL_BUTTON_CLEAR: SetEditText(""); break; case CTL_EDIT: { CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), CTL_EDIT); OnMessage(msg); // update callback I guess? if (m_pCharCallback) { // we did _something_, so make sure our search message filter is reset m_pCharCallback(this, msg.GetLabel()); } m_text = msg.GetLabel(); return true; } default: OnClickButton(iControl); break; } } break; case GUI_MSG_SET_TEXT: case GUI_MSG_INPUT_TEXT_EDIT: { // the edit control only handles these messages if it is either focues // or its specific control ID is set in the message. As neither is the // case here (focus is on one of the keyboard buttons) we have to force // the control ID of the message to the control ID of the edit control // (unfortunately we have to create a whole copy of the message object for that) CGUIMessage messageCopy(message.GetMessage(), message.GetSenderId(), CTL_EDIT, message.GetParam1(), message.GetParam2(), message.GetItem()); messageCopy.SetLabel(message.GetLabel()); // ensure this goes to the edit control CGUIControl *edit = GetControl(CTL_EDIT); if (edit) edit->OnMessage(messageCopy); // close the dialog if requested if (message.GetMessage() == GUI_MSG_SET_TEXT && message.GetParam1() > 0) OnOK(); return true; } } return CGUIDialog::OnMessage(message); }
void CGUIDialogKeyboardGeneric::ResetShiftAndSymbols() { if (m_bShift) OnShift(); if (m_keyType == SYMBOLS) OnSymbols(); m_lastRemoteClickTime = 0; }
bool CGUIDialogKeyboardGeneric::OnAction(const CAction &action) { bool handled(true); if (action.GetID() == ACTION_BACKSPACE) { Backspace(); } else if (action.GetID() == ACTION_ENTER) { OnOK(); } else if (action.GetID() == ACTION_CURSOR_LEFT) { MoveCursor( -1); } else if (action.GetID() == ACTION_CURSOR_RIGHT) { if ((unsigned int) GetCursorPos() == m_strEdit.size() && (m_strEdit.size() == 0 || m_strEdit[m_strEdit.size() - 1] != ' ')) { // add a space Character(L' '); } else MoveCursor(1); } else if (action.GetID() == ACTION_SHIFT) { OnShift(); } else if (action.GetID() == ACTION_SYMBOLS) { OnSymbols(); } else if (action.GetID() >= REMOTE_0 && action.GetID() <= REMOTE_9) { OnRemoteNumberClick(action.GetID()); } else if (action.GetID() >= KEY_VKEY && action.GetID() < KEY_ASCII) { // input from the keyboard (vkey, not ascii) uint8_t b = action.GetID() & 0xFF; if (b == XBMCVK_HOME) { MoveCursor(-GetCursorPos()); } else if (b == XBMCVK_END) { MoveCursor(m_strEdit.GetLength() - GetCursorPos()); } else if (b == XBMCVK_LEFT) { MoveCursor( -1); } else if (b == XBMCVK_RIGHT) { MoveCursor(1); } else if (b == XBMCVK_RETURN || b == XBMCVK_NUMPADENTER) { OnOK(); } else if (b == XBMCVK_DELETE) { if (GetCursorPos() < m_strEdit.GetLength()) { MoveCursor(1); Backspace(); } } else if (b == XBMCVK_BACK) Backspace(); else if (b == XBMCVK_ESCAPE) Close(); } else if (action.GetID() >= KEY_ASCII) { // input from the keyboard //char ch = action.GetID() & 0xFF; switch (action.GetUnicode()) { case 13: // enter case 10: // enter OnOK(); break; case 8: // backspace Backspace(); break; case 27: // escape Close(); break; default: //use character input Character(action.GetUnicode()); break; } } else // unhandled by us - let's see if the baseclass wants it handled = CGUIDialog::OnAction(action); if (handled && m_pCharCallback) { // we did _something_, so make sure our search message filter is reset m_pCharCallback(this, GetText()); } return handled; }
bool CGUIDialogKeyboard::OnAction(const CAction &action) { bool handled(true); if (action.GetID() == ACTION_BACKSPACE) { Backspace(); } else if (action.GetID() == ACTION_ENTER) { OnOK(); } else if (action.GetID() == ACTION_CURSOR_LEFT) { MoveCursor( -1); } else if (action.GetID() == ACTION_CURSOR_RIGHT) { if ((unsigned int) GetCursorPos() == m_strEdit.size() && (m_strEdit.size() == 0 || m_strEdit[m_strEdit.size() - 1] != ' ')) { // add a space Character(L' '); } else MoveCursor(1); } else if (action.GetID() == ACTION_SHIFT) { OnShift(); } else if (action.GetID() == ACTION_SYMBOLS) { OnSymbols(); } else if (action.GetID() >= REMOTE_0 && action.GetID() <= REMOTE_9) { OnRemoteNumberClick(action.GetID()); } else if (action.GetID() >= KEY_VKEY && action.GetID() < KEY_ASCII) { // input from the keyboard (vkey, not ascii) uint8_t b = action.GetID() & 0xFF; if (b == 0x88) // home { MoveCursor(-GetCursorPos()); } else if (b == 0x89) // end { MoveCursor(m_strEdit.GetLength() - GetCursorPos()); } else if (b == 0x82) // left { MoveCursor( -1); } else if (b == 0x83) // right { MoveCursor(1); } else if (b == 0x0D || b == 0x65) // enter { OnOK(); } else if (b == 0x87) // delete { if (GetCursorPos() < m_strEdit.GetLength()) { MoveCursor(1); Backspace(); } } else if (b == 0x08) Backspace(); // backspace else if (b == 0x1B) Close(); // escape } else if (action.GetID() >= KEY_ASCII) { // input from the keyboard //char ch = action.GetID() & 0xFF; switch (action.GetUnicode()) { case 13: // enter case 10: // enter OnOK(); break; case 8: // backspace Backspace(); break; case 27: // escape Close(); break; default: //use character input Character(action.GetUnicode()); break; } } else // unhandled by us - let's see if the baseclass wants it handled = CGUIDialog::OnAction(action); if (handled && m_filtering == FILTERING_SEARCH) { // we did _something_, so make sure our search message filter is reset SendSearchMessage(); } return handled; }
bool CGUIDialogKeyboardGeneric::OnMessage(CGUIMessage& message) { switch ( message.GetMessage() ) { case GUI_MSG_CLICKED: { int iControl = message.GetSenderId(); switch (iControl) { case CTL_BUTTON_DONE: OnOK(); break; case CTL_BUTTON_CANCEL: Close(); break; case CTL_BUTTON_SHIFT: OnShift(); break; case CTL_BUTTON_CAPS: if (m_keyType == LOWER) m_keyType = CAPS; else if (m_keyType == CAPS) m_keyType = LOWER; UpdateButtons(); break; case CTL_BUTTON_SYMBOLS: OnSymbols(); break; case CTL_BUTTON_LEFT: MoveCursor( -1); break; case CTL_BUTTON_RIGHT: MoveCursor(1); break; case CTL_BUTTON_IP_ADDRESS: OnIPAddress(); break; case CTL_BUTTON_CLEAR: SetEditText(""); break; case CTL_EDIT: { CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), CTL_EDIT); OnMessage(msg); // update callback I guess? if (m_pCharCallback) { // we did _something_, so make sure our search message filter is reset m_pCharCallback(this, msg.GetLabel()); } m_text = msg.GetLabel(); return true; } default: OnClickButton(iControl); break; } } break; case GUI_MSG_SET_TEXT: case GUI_MSG_INPUT_TEXT: case GUI_MSG_INPUT_TEXT_EDIT: { // ensure this goes to the edit control CGUIControl *edit = GetControl(CTL_EDIT); if (edit) edit->OnMessage(message); // close the dialog if requested if (message.GetMessage() == GUI_MSG_SET_TEXT && message.GetParam1() > 0) OnOK(); return true; } } return CGUIDialog::OnMessage(message); }
bool CGUIDialogKeyboardGeneric::OnMessage(CGUIMessage& message) { CGUIDialog::OnMessage(message); switch ( message.GetMessage() ) { case GUI_MSG_CLICKED: { int iControl = message.GetSenderId(); switch (iControl) { case CTL_BUTTON_DONE: OnOK(); break; case CTL_BUTTON_CANCEL: Close(); break; case CTL_BUTTON_SHIFT: OnShift(); break; case CTL_BUTTON_CAPS: OnCapsLock(); break; case CTL_BUTTON_SYMBOLS: OnSymbols(); break; case CTL_BUTTON_LEFT: MoveCursor( -1); break; case CTL_BUTTON_RIGHT: MoveCursor(1); break; case CTL_BUTTON_IP_ADDRESS: OnIPAddress(); break; case CTL_BUTTON_CLEAR: SetText(""); break; default: m_lastRemoteKeyClicked = 0; OnClickButton(iControl); break; } } break; case GUI_MSG_SET_TEXT: SetText(message.GetLabel()); // close the dialog if requested if (message.GetParam1() > 0) OnOK(); break; case GUI_MSG_INPUT_TEXT: InputText(message.GetLabel()); break; case GUI_MSG_INPUT_TEXT_EDIT: InputTextEditing(message.GetLabel(), message.GetParam1(), message.GetParam2()); break; } return true; }
bool CGUIDialogKeyboardGeneric::OnAction(const CAction &action) { bool handled(true); if (action.GetID() == ACTION_BACKSPACE) { Backspace(); } else if (action.GetID() == ACTION_ENTER) { OnOK(); } else if (action.GetID() == ACTION_CURSOR_LEFT) { MoveCursor( -1); } else if (action.GetID() == ACTION_CURSOR_RIGHT) { if (m_strEditing.empty() && (unsigned int) GetCursorPos() == m_strEdit.size() && (m_strEdit.size() == 0 || m_strEdit[m_strEdit.size() - 1] != ' ')) { // add a space Character(L' '); } else MoveCursor(1); } else if (action.GetID() == ACTION_SHIFT) { OnShift(); } else if (action.GetID() == ACTION_SYMBOLS) { OnSymbols(); } else if (action.GetID() >= REMOTE_0 && action.GetID() <= REMOTE_9) { OnRemoteNumberClick(action.GetID()); } else if (action.GetID() == ACTION_PASTE) { OnPasteClipboard(); } else if ( (action.GetID() >= KEY_VKEY && action.GetID() < KEY_ASCII) || (action.GetButtonCode() >= KEY_VKEY && action.GetButtonCode() < KEY_ASCII) ) { // input from the keyboard (vkey, not ascii) if (!m_strEditing.empty()) return handled; uint8_t b = action.GetButtonCode() ? action.GetButtonCode() & 0xFF : action.GetID() & 0xFF; switch (b) { case XBMCVK_HOME: SetCursorPos(0); break; case XBMCVK_END: SetCursorPos(m_strEdit.size()); break; case XBMCVK_LEFT: MoveCursor( -1); break; case XBMCVK_RIGHT: MoveCursor(1); break; case XBMCVK_RETURN: case XBMCVK_NUMPADENTER: OnOK(); break; case XBMCVK_DELETE: if (GetCursorPos() < (int)m_strEdit.size()) { MoveCursor(1); Backspace(); } break; case XBMCVK_BACK: Backspace(); break; case XBMCVK_ESCAPE: Close(); break; case XBMCVK_LSHIFT: case XBMCVK_RSHIFT: OnShift(); break; case XBMCVK_CAPSLOCK: OnCapsLock(); break; } } else if (action.GetID() >= KEY_ASCII) { // input from the keyboard //char ch = action.GetID() & 0xFF; int ch = action.GetUnicode(); if( m_keyType == LOWER && m_bShift ) { if (ch >= 'a' && ch <= 'z') ch -= 32; OnShift(); } else if( m_keyType == CAPS && !m_bShift ) { if (ch >= 'a' && ch <= 'z') ch -= 32; } else if( m_keyType == CAPS && m_bShift ) OnShift(); // Ignore non-printing characters if ( !((0 <= ch && ch < 0x8) || (0xE <= ch && ch < 0x1B) || (0x1C <= ch && ch < 0x20)) ) { switch (ch) { case 0x8: // backspace Backspace(); break; case 0x9: // Tab (do nothing) case 0xB: // Non-printing character, ignore case 0xC: // Non-printing character, ignore break; case 0xA: // enter case 0xD: // enter OnOK(); break; case 0x1B: // escape Close(); break; case 0x7F: // Delete if (GetCursorPos() < (int)m_strEdit.size()) { MoveCursor(1); Backspace(); } break; default: //use character input // When we support text input method, we only accept text by gui text message. if (!g_Windowing.IsTextInputEnabled()) Character(ch); //Character(action.GetUnicode()); break; } } } else // unhandled by us - let's see if the baseclass wants it handled = CGUIDialog::OnAction(action); if (handled && m_pCharCallback) { // we did _something_, so make sure our search message filter is reset m_pCharCallback(this, GetText()); } return handled; }
bool CGUIDialogKeyboard::OnAction(const CAction &action) { // check if we're doing a search, and if so, interrupt the search timer. DWORD now = timeGetTime(); if (m_lastSearchUpdate || m_lastSearchUpdate + SEARCH_DELAY >= now) m_lastSearchUpdate = now; if (action.wID == ACTION_BACKSPACE #ifdef __APPLE__ || action.wID == ACTION_PARENT_DIR #endif ) { Backspace(); return true; } else if (action.wID == ACTION_ENTER) { OnOK(); return true; } else if (action.wID == ACTION_CURSOR_LEFT) { MoveCursor( -1); return true; } else if (action.wID == ACTION_CURSOR_RIGHT) { if ((unsigned int) GetCursorPos() == m_strEdit.size() && (m_strEdit.size() == 0 || m_strEdit[m_strEdit.size() - 1] != ' ')) { // add a space Character(L' '); } else MoveCursor(1); return true; } else if (action.wID == ACTION_SHIFT) { OnShift(); return true; } else if (action.wID == ACTION_SYMBOLS) { OnSymbols(); return true; } else if (action.wID >= REMOTE_0 && action.wID <= REMOTE_9) { OnRemoteNumberClick(action.wID); return true; } else if (action.wID >= (WORD)KEY_VKEY && action.wID < (WORD)KEY_ASCII) { // input from the keyboard (vkey, not ascii) BYTE b = action.wID & 0xFF; if (b == 0x25) MoveCursor( -1); // left else if (b == 0x27) MoveCursor(1); // right else if (b == 0x0D) OnOK(); // enter else if (b == 0x08) Backspace(); // backspace else if (b == 0x1B) Close(); // escape else if (b == 0x20) Character(b); // space return true; } else if (action.wID >= KEY_ASCII) { // input from the keyboard //char ch = action.wID & 0xFF; switch (action.unicode) { case 13: // enter case 10: // enter OnOK(); break; case 8: // backspace Backspace(); break; case 27: // escape Close(); break; default: //use character input Character(action.unicode); break; } return true; } return CGUIDialog::OnAction(action); }