示例#1
0
bool CGUIDialogKeyboardGeneric::OnAction(const CAction &action)
{
  bool handled = true;
  if (action.GetID() == (KEY_VKEY | XBMCVK_BACK))
    Backspace();
  else 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;
    wchar_t unicode = action.GetUnicode();
    if (unicode)
    {
      std::wstring wch = L"";
      wch.insert(wch.begin(), unicode);
      std::string ch;
      g_charsetConverter.wToUTF8(wch, ch);
      handled = CodingCharacter(ch);
      if (!handled)
      {
        // 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;
}
示例#2
0
bool CGUIDialogNumeric::OnAction(const CAction &action)
{
  if (action.GetID() == ACTION_NEXT_ITEM)
    OnNext();
  else if (action.GetID() == ACTION_PREV_ITEM)
    OnPrevious();
  else if (action.GetID() == ACTION_BACKSPACE)
    OnBackSpace();
  else if (action.GetID() == ACTION_ENTER)
    OnOK();
  else if (action.GetID() >= REMOTE_0 && action.GetID() <= REMOTE_9)
    OnNumber(action.GetID() - REMOTE_0);
  else if (action.GetID() >= KEY_VKEY && action.GetID() < KEY_ASCII)
  { // input from the keyboard (vkey, not ascii)
    BYTE b = action.GetID() & 0xFF;
    if (b == XBMCVK_LEFT) OnPrevious();
    else if (b == XBMCVK_RIGHT) OnNext();
    else if (b == XBMCVK_RETURN || b == XBMCVK_NUMPADENTER) OnOK();
    else if (b == XBMCVK_BACK) OnBackSpace();
    else if (b == XBMCVK_ESCAPE) OnCancel();
  }
  else if (action.GetID() >= KEY_ASCII) // FIXME make it KEY_UNICODE
  { // input from the keyboard
    if (action.GetUnicode() == 10 || action.GetUnicode() == 13) OnOK(); // enter
    else if (action.GetUnicode() == 8) OnBackSpace(); // backspace
    else if (action.GetUnicode() == 27) OnCancel(); // escape
    else if (action.GetUnicode() >= 48 && action.GetUnicode() < 58)  // number
      OnNumber(action.GetUnicode() - 48);
  }
  else
    return CGUIDialog::OnAction(action);
  return true;
}
示例#3
0
bool CGUIDialogNumeric::OnAction(const CAction &action)
{
  if (action.GetID() >= ACTION_MOVE_LEFT &&  action.GetID() <= ACTION_MOVE_DOWN)
    m_autoClosing = false;

  if (action.GetID() == ACTION_CLOSE_DIALOG || action.GetID() == ACTION_PREVIOUS_MENU)
    OnCancel();
  else if (action.GetID() == ACTION_NEXT_ITEM)
    OnNext();
  else if (action.GetID() == ACTION_PREV_ITEM)
    OnPrevious();
  else if (action.GetID() == ACTION_BACKSPACE)
    OnBackSpace();
  else if (action.GetID() == ACTION_ENTER)
    OnOK();
  else if (action.GetID() >= REMOTE_0 && action.GetID() <= REMOTE_9)
    OnNumber(action.GetID() - REMOTE_0);
  else if (action.GetID() >= KEY_VKEY && action.GetID() < KEY_ASCII)
  { // input from the keyboard (vkey, not ascii)
    BYTE b = action.GetID() & 0xFF;
    if (b == 0x25) OnPrevious();     // left
    else if (b == 0x27) OnNext();  // right
    else if (b == 0x0D) OnOK();         // enter
    else if (b == 0x08) OnBackSpace();    // backspace
    else if (b == 0x1B) OnCancel();        // escape
  }
  else if (action.GetID() >= KEY_ASCII) // FIXME make it KEY_UNICODE
  { // input from the keyboard
    if (action.GetUnicode() == 10 || action.GetUnicode() == 13) OnOK(); // enter
    else if (action.GetUnicode() == 8) OnBackSpace(); // backspace
    else if (action.GetUnicode() == 27) OnCancel(); // escape
    else if (action.GetUnicode() >= 48 && action.GetUnicode() < 58)  // number
      OnNumber(action.GetUnicode() - 48);
  }
  else
    return CGUIDialog::OnAction(action);
  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 ((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;
}
示例#5
0
bool CGUIEditControl::OnAction(const CAction &action)
{
    ValidateCursor();

    if (m_inputType != INPUT_TYPE_READONLY)
    {
        if (action.GetID() == ACTION_BACKSPACE)
        {
            // backspace
            if (m_cursorPos)
            {
                if (!ClearMD5())
                    m_text2.erase(--m_cursorPos, 1);
                UpdateText();
            }
            return true;
        }
        else if (action.GetID() == ACTION_MOVE_LEFT ||
                 action.GetID() == ACTION_CURSOR_LEFT)
        {
            if (m_cursorPos > 0)
            {
                m_cursorPos--;
                UpdateText(false);
                return true;
            }
        }
        else if (action.GetID() == ACTION_MOVE_RIGHT ||
                 action.GetID() == ACTION_CURSOR_RIGHT)
        {
            if ((unsigned int) m_cursorPos < m_text2.size())
            {
                m_cursorPos++;
                UpdateText(false);
                return true;
            }
        }
        else if (action.GetID() == ACTION_PASTE)
        {
            ClearMD5();
            OnPasteClipboard();
            return true;
        }
        else if (action.GetID() >= KEY_VKEY && action.GetID() < KEY_ASCII && m_edit.empty())
        {
            // input from the keyboard (vkey, not ascii)
            BYTE b = action.GetID() & 0xFF;
            if (b == XBMCVK_HOME)
            {
                m_cursorPos = 0;
                UpdateText(false);
                return true;
            }
            else if (b == XBMCVK_END)
            {
                m_cursorPos = m_text2.length();
                UpdateText(false);
                return true;
            }
            if (b == XBMCVK_LEFT && m_cursorPos > 0)
            {
                m_cursorPos--;
                UpdateText(false);
                return true;
            }
            if (b == XBMCVK_RIGHT && m_cursorPos < m_text2.length())
            {
                m_cursorPos++;
                UpdateText(false);
                return true;
            }
            if (b == XBMCVK_DELETE)
            {
                if (m_cursorPos < m_text2.length())
                {
                    if (!ClearMD5())
                        m_text2.erase(m_cursorPos, 1);
                    UpdateText();
                    return true;
                }
            }
            if (b == XBMCVK_BACK)
            {
                if (m_cursorPos > 0)
                {
                    if (!ClearMD5())
                        m_text2.erase(--m_cursorPos, 1);
                    UpdateText();
                }
                return true;
            }
            else if (b == XBMCVK_RETURN || b == XBMCVK_NUMPADENTER)
            {
                // enter - send click message, but otherwise ignore
                SEND_CLICK_MESSAGE(GetID(), GetParentID(), 1);
                return true;
            }
            else if (b == XBMCVK_ESCAPE)
            {   // escape - fallthrough to default action
                return CGUIButtonControl::OnAction(action);
            }
        }
        else if (action.GetID() >= KEY_ASCII)
        {
            // input from the keyboard
            int ch = action.GetUnicode();
            // ignore non-printing characters
            if ( !((0 <= ch && ch < 0x8) || (0xE <= ch && ch < 0x1B) || (0x1C <= ch && ch < 0x20)) )
            {
                switch (ch)
                {
                case 9:  // tab, ignore
                case 11: // Non-printing character, ignore
                case 12: // Non-printing character, ignore
                    break;
                case 10:
                case 13:
                {
                    // enter - send click message, but otherwise ignore
                    SEND_CLICK_MESSAGE(GetID(), GetParentID(), 1);
                    return true;
                }
                case 27:
                {   // escape - fallthrough to default action
                    return CGUIButtonControl::OnAction(action);
                }
                case 8:
                {
                    // backspace
                    if (m_cursorPos)
                    {
                        if (!ClearMD5())
                            m_text2.erase(--m_cursorPos, 1);
                    }
                    break;
                }
                case 127:
                {   // delete
                    if (m_cursorPos < m_text2.length())
                    {
                        if (!ClearMD5())
                            m_text2.erase(m_cursorPos, 1);
                    }
                    break;
                }
                default:
                {
                    if (!g_Windowing.IsTextInputEnabled())
                    {
                        ClearMD5();
                        m_edit.clear();
                        m_text2.insert(m_text2.begin() + m_cursorPos++, (WCHAR)action.GetUnicode());
                    }
                    break;
                }
                }
                UpdateText();
                return true;
            }
        }
        else if (action.GetID() >= REMOTE_0 && action.GetID() <= REMOTE_9)
        {   // input from the remote
            ClearMD5();
            m_edit.clear();
            OnSMSCharacter(action.GetID() - REMOTE_0);
            return true;
        }
        else if (action.GetID() == ACTION_INPUT_TEXT)
        {
            m_edit.clear();
            std::wstring str;
            g_charsetConverter.utf8ToW(action.GetText(), str);
            m_text2.insert(m_cursorPos, str);
            m_cursorPos += str.size();
            UpdateText();
            return true;
        }
    }
    return CGUIButtonControl::OnAction(action);
}
示例#6
0
bool CGUIEditControl::OnAction(const CAction &action)
{
  ValidateCursor();

  if (m_inputType != INPUT_TYPE_READONLY)
  {
    if (action.GetID() == ACTION_BACKSPACE)
    {
      // backspace
      if (m_cursorPos)
      {
        if (!ClearMD5())
          m_text2.erase(--m_cursorPos, 1);
        UpdateText();
      }
      return true;
    }
    else if (action.GetID() == ACTION_MOVE_LEFT)
    {
      if (m_cursorPos > 0)
      {
        m_cursorPos--;
        UpdateText(false);
        return true;
      }
    }
    else if (action.GetID() == ACTION_MOVE_RIGHT)
    {
      if ((unsigned int) m_cursorPos < m_text2.size())
      {
        m_cursorPos++;
        UpdateText(false);
        return true;
      }
    }
    else if (action.GetID() == ACTION_PASTE)
    {
      ClearMD5();
      OnPasteClipboard();
    }
    else if (action.GetID() >= KEY_VKEY && action.GetID() < KEY_ASCII)
    {
      // input from the keyboard (vkey, not ascii)
      BYTE b = action.GetID() & 0xFF;
      if (b == XBMCVK_HOME)
      {
        m_cursorPos = 0;
        UpdateText(false);
        return true;
      }
      else if (b == XBMCVK_END)
      {
        m_cursorPos = m_text2.length();
        UpdateText(false);
        return true;
      }
      if (b == XBMCVK_LEFT && m_cursorPos > 0)
      {
        m_cursorPos--;
        UpdateText(false);
        return true;
      }
      if (b == XBMCVK_RIGHT && m_cursorPos < m_text2.length())
      {
        m_cursorPos++;
        UpdateText(false);
        return true;
      }
      if (b == XBMCVK_DELETE)
      {
        if (m_cursorPos < m_text2.length())
        {
          if (!ClearMD5())
            m_text2.erase(m_cursorPos, 1);
          UpdateText();
          return true;
        }
      }
      if (b == XBMCVK_BACK)
      {
        if (m_cursorPos > 0)
        {
          if (!ClearMD5())
            m_text2.erase(--m_cursorPos, 1);
          UpdateText();
        }
        return true;
      }
    }
    else if (action.GetID() >= KEY_ASCII)
    {
      // input from the keyboard
      switch (action.GetUnicode())
      {
      case '\t':
        break;
      case 10:
      case 13:
        {
          // enter - send click message, but otherwise ignore
          SEND_CLICK_MESSAGE(GetID(), GetParentID(), 1);
          return true;
        }
      case 27:
        { // escape - fallthrough to default action
          return CGUIButtonControl::OnAction(action);
        }
      case 8:
        {
          // backspace
          if (m_cursorPos)
          {
            if (!ClearMD5())
              m_text2.erase(--m_cursorPos, 1);
          }
          break;
        }
      default:
        {
          ClearMD5();
          m_text2.insert(m_text2.begin() + m_cursorPos++, (WCHAR)action.GetUnicode());
          break;
        }
      }
      UpdateText();
      return true;
    }
    else if (action.GetID() >= REMOTE_0 && action.GetID() <= REMOTE_9)
    { // input from the remote
      ClearMD5();
      if (m_inputType == INPUT_TYPE_FILTER)
      { // filtering - use single number presses
        m_text2.insert(m_text2.begin() + m_cursorPos++, L'0' + (action.GetID() - REMOTE_0));
        UpdateText();
      }
      else
        OnSMSCharacter(action.GetID() - REMOTE_0);
      return true;
    }
  }
  return CGUIButtonControl::OnAction(action);
}
示例#7
0
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::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;
}