summaryrefslogtreecommitdiffstats
path: root/xbmc/dialogs/GUIDialogKeyboardTouch.cpp
blob: e9511cec1aeb386a2649b5a6c89d531aa06b3dcb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
 *  Copyright (C) 2012-2018 Team Kodi
 *  This file is part of Kodi - https://kodi.tv
 *
 *  SPDX-License-Identifier: GPL-2.0-or-later
 *  See LICENSES/README.md for more information.
 */

#include "GUIDialogKeyboardTouch.h"
#if defined(TARGET_DARWIN_EMBEDDED)
#include "platform/darwin/ios-common/DarwinEmbedKeyboard.h"
#endif

CGUIDialogKeyboardTouch::CGUIDialogKeyboardTouch()
: CGUIDialog(WINDOW_DIALOG_KEYBOARD_TOUCH, "")
, CGUIKeyboard()
, CThread("keyboard")
, m_pCharCallback(NULL)
{
}

bool CGUIDialogKeyboardTouch::ShowAndGetInput(char_callback_t pCallback, const std::string &initialString, std::string &typedString, const std::string &heading, bool bHiddenInput)
{
#if defined(TARGET_DARWIN_EMBEDDED)
  m_keyboard.reset(new CDarwinEmbedKeyboard());
#endif

  if (!m_keyboard)
    return false;

  m_pCharCallback = pCallback;
  m_initialString = initialString;
  m_typedString = typedString;
  m_heading = heading;
  m_bHiddenInput = bHiddenInput;

  m_confirmed = false;
  Initialize();
  Open();

  m_keyboard.reset();

  if (m_confirmed)
  {
    typedString = m_typedString;
    return true;
  }

  return false;
}

bool CGUIDialogKeyboardTouch::SetTextToKeyboard(const std::string &text, bool closeKeyboard)
{
  if (m_keyboard)
    return m_keyboard->SetTextToKeyboard(text, closeKeyboard);

  return false;
}

void CGUIDialogKeyboardTouch::Cancel()
{
  if (m_keyboard)
    m_keyboard->Cancel();
}

int CGUIDialogKeyboardTouch::GetWindowId() const
{
  return GetID();
}

void CGUIDialogKeyboardTouch::OnInitWindow()
{
  CGUIDialog::OnInitWindow();
  m_windowLoaded = true;
  m_active = true;
  Create();
}

void CGUIDialogKeyboardTouch::Process()
{
  if (m_keyboard)
  {
    m_confirmed = m_keyboard->ShowAndGetInput(m_pCharCallback, m_initialString, m_typedString, m_heading, m_bHiddenInput);
  }
  Close();
}