// Show keyboard with initial value (aTextString) and replace with result string. // Returns: true - successful display and input (empty result may return true or false depending on parameter) // false - unsucessful display of the keyboard or cancelled editing bool CGUIDialogKeyboard::ShowAndGetInput(CStdString& aTextString, const CVariant &heading, bool allowEmptyResult, bool hiddenInput /* = false */) { CGUIDialogKeyboard *pKeyboard = (CGUIDialogKeyboard*)g_windowManager.GetWindow(WINDOW_DIALOG_KEYBOARD); if (!pKeyboard) return false; // setup keyboard pKeyboard->Initialize(); pKeyboard->SetHeading(heading); pKeyboard->SetHiddenInput(hiddenInput); pKeyboard->SetText(aTextString); // do this using a thread message to avoid render() conflicts ThreadMessage tMsg = {TMSG_DIALOG_DOMODAL, WINDOW_DIALOG_KEYBOARD, g_windowManager.GetActiveWindow()}; g_application.getApplicationMessenger().SendMessage(tMsg, true); pKeyboard->Close(); // If have text - update this. if (pKeyboard->IsConfirmed()) { aTextString = pKeyboard->GetText(); if (!allowEmptyResult && aTextString.IsEmpty()) return false; return true; } else return false; }
PyObject* Keyboard_GetText(Keyboard *self, PyObject *args) { CGUIDialogKeyboard *pKeyboard = (CGUIDialogKeyboard*)g_windowManager.GetWindow(WINDOW_DIALOG_KEYBOARD); if(!pKeyboard) { PyErr_SetString(PyExc_SystemError, "Unable to load keyboard"); return NULL; } return Py_BuildValue((char*)"s", pKeyboard->GetText().c_str()); }
PyObject* Keyboard_GetText(Keyboard *self, PyObject *args) { CGUIDialogKeyboard *pKeyboard = ((Keyboard*)self)->dlg; if(!pKeyboard) { PyErr_SetString(PyExc_SystemError, "Unable to load keyboard"); return NULL; } PyXBMCGUILock(); CStdString result = pKeyboard->GetText(); PyXBMCGUIUnlock(); return Py_BuildValue((char*)"s", result.c_str()); }