Skip to content

Commit

Permalink
[guilib/input] - replace GUI_MSG_INPUT_TEXT with ACTION_INPUT_TEXT
Browse files Browse the repository at this point in the history
  • Loading branch information
Memphiz committed Jan 7, 2015
1 parent 354e8da commit a0b2f40
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
1 change: 0 additions & 1 deletion xbmc/GUIUserMessages.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,4 @@
#define GUI_MSG_SHOW_PICTURE GUI_MSG_USER + 36

// Sent to text field to support 'input method'
#define GUI_MSG_INPUT_TEXT GUI_MSG_USER + 37
#define GUI_MSG_INPUT_TEXT_EDIT GUI_MSG_USER + 38
7 changes: 3 additions & 4 deletions xbmc/dialogs/GUIDialogKeyboardGeneric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ bool CGUIDialogKeyboardGeneric::OnMessage(CGUIMessage& message)
break;

case GUI_MSG_SET_TEXT:
case GUI_MSG_INPUT_TEXT:
case GUI_MSG_INPUT_TEXT_EDIT:
{
// the edit control only handles these messages if it is either focues
Expand Down Expand Up @@ -270,9 +269,9 @@ void CGUIDialogKeyboardGeneric::Character(const std::string &ch)
CGUIControl *edit = GetControl(CTL_EDIT);
if (edit)
{
CGUIMessage msg(GUI_MSG_INPUT_TEXT, GetID(), CTL_EDIT);
msg.SetLabel(ch);
edit->OnMessage(msg);
CAction action(ACTION_INPUT_TEXT);
action.SetText(ch);
edit->OnAction(action);
}
}

Expand Down
21 changes: 10 additions & 11 deletions xbmc/guilib/GUIEditControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,6 @@ bool CGUIEditControl::OnMessage(CGUIMessage &message)
SetLabel2(message.GetLabel());
UpdateText();
}
else if (message.GetMessage() == GUI_MSG_INPUT_TEXT && !message.GetLabel().empty()
&& (HasFocus() || message.GetControlId() == GetID()))
{
m_edit.clear();
std::wstring str;
g_charsetConverter.utf8ToW(message.GetLabel(), str);
m_text2.insert(m_cursorPos, str);
m_cursorPos += str.size();
UpdateText();
return true;
}
else if (message.GetMessage() == GUI_MSG_INPUT_TEXT_EDIT && HasFocus())
{
g_charsetConverter.utf8ToW(message.GetLabel(), m_edit);
Expand Down Expand Up @@ -292,6 +281,16 @@ bool CGUIEditControl::OnAction(const CAction &action)
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);
}
Expand Down
11 changes: 8 additions & 3 deletions xbmc/osx/OSXTextInputResponder.mm
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include "guilib/GUIWindowManager.h"
#include "GUIUserMessages.h"
#include "utils/log.h"
#include "ApplicationMessenger.h"
#include "guilib/key.h"
#undef BOOL

void SendKeyboardText(const char *text)
Expand All @@ -37,9 +39,12 @@ void SendKeyboardText(const char *text)
if ((unsigned char)*text < ' ' || *text == 127)
return;

CGUIMessage msg(GUI_MSG_INPUT_TEXT, 0, 0);
msg.SetLabel(text);
g_windowManager.SendThreadMessage(msg, g_windowManager.GetFocusedWindow());
ThreadMessage tMsg = {TMSG_GUI_ACTION};
tMsg.param1 = WINDOW_INVALID;
CAction *action = new CAction(ACTION_INPUT_TEXT);
action->SetText(text);
tMsg.lpVoid = action;
CApplicationMessenger::Get().SendMessage(tMsg, false);
}

void SendEditingText(const char *text, unsigned int location, unsigned int length)
Expand Down

0 comments on commit a0b2f40

Please sign in to comment.