- Moderator
- #1
Hi
I want to show a dialog where the user can log in to a web-based service (HeadWeb). This involves a username and password.
In my main-file (HeadWeb.cs) I open a custom dialog that shows three buttons; "enter username", "enter password" and "login now" which is called when the user pressed a "login" button in the main XML-file:
HeadWeb.cs
So far so good. The dialog opens, and shows my dialog with the three buttons.
Now the user is supposed to click "username" and enter his username in the virtual keyboard:
HeadWebLogin.cs
GetUserInputString() function is a standard virtual keyboard, used many places in MediaPortal:
My problem is that when the user has entered some text in the virtual keyboard and presses "enter", the first dialog is not shown any more. Same thing happens if the user cancels the virtual keyboard (Esc).
Isn't it possible to put a DoModal on top of a DoModal?
I was looking for this flow:
Press "Login" button in main GUI
Login-window with three buttons is shown
Press "Enter username" button
Virtual keyboard comes up
User enters text, and virtual keyboard closes
Press "Enter pasword" button
Virtual keyboard comes up
User enters text, and virtual keyboard closes
Press "Login"
User is logged in, and Login-window closes
I have now tried for several days to crack this
I want to show a dialog where the user can log in to a web-based service (HeadWeb). This involves a username and password.
In my main-file (HeadWeb.cs) I open a custom dialog that shows three buttons; "enter username", "enter password" and "login now" which is called when the user pressed a "login" button in the main XML-file:
HeadWeb.cs
Code:
// Check if skin-file for Login dialog exists
if (System.IO.File.Exists(GUIGraphicsContext.Skin + @"\HeadWebLogin.xml"))
{
GUILogin loginDlg = (GUILogin)GUIWindowManager.GetWindow(GUILogin.ID);
// Initialize Dialog
if (loginDlg != null)
{
loginDlg.Reset();
loginDlg.SetHeading("Login to HeadWeb");
loginDlg.DoModal(GetID);
}
}
So far so good. The dialog opens, and shows my dialog with the three buttons.
Now the user is supposed to click "username" and enter his username in the virtual keyboard:
HeadWebLogin.cs
Code:
protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType)
{
if (control == btnEnterUsername)
{
string userNameString = string.Empty;
GetUserInputString(ref userNameString);
if (userNameString.Length > 0)
{
//Do stuff
HeadWebSettings.Instance.s_username = userNameString;
}
}
if (control == btnEnterPassword)
{
string passwordString = string.Empty;
GetUserInputString(ref passwordString);
if (passwordString.Length > 0)
{
//Do stuff
HeadWebSettings.Instance.s_password = passwordString;
}
}
if (control == btnOK)
{
HeadWeb hw = (HeadWeb)GUIWindowManager.GetWindow(HeadWeb.ID);
HeadWebSettings.Instance.s_cc = new CookieContainer();
bool loginresult = hw.loginUser(HeadWebSettings.Instance.s_username, HeadWebSettings.Instance.s_password);
if (loginresult)
{
Log.Info("login ok");
HeadWebSettings.Instance.s_loggedin = true;
}
GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT, GetID, 0, 0, 0, 0, null);
OnMessage(msg);
GUIWindowManager.UnRoute();
}
base.OnClicked(controlId, control, actionType);
}
GetUserInputString() function is a standard virtual keyboard, used many places in MediaPortal:
Code:
private bool GetUserInputString(ref string sString)
{
VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)Window.WINDOW_VIRTUAL_KEYBOARD);
if (null == keyboard)
{
return false;
}
keyboard.IsSearchKeyboard = true;
keyboard.Reset();
keyboard.Text = sString;
keyboard.DoModal(GUIWindowManager.ActiveWindow); // show it...
if (keyboard.IsConfirmed)
{
sString = keyboard.Text;
}
return keyboard.IsConfirmed;
}
My problem is that when the user has entered some text in the virtual keyboard and presses "enter", the first dialog is not shown any more. Same thing happens if the user cancels the virtual keyboard (Esc).
Isn't it possible to put a DoModal on top of a DoModal?
I was looking for this flow:
Press "Login" button in main GUI
Login-window with three buttons is shown
Press "Enter username" button
Virtual keyboard comes up
User enters text, and virtual keyboard closes
Press "Enter pasword" button
Virtual keyboard comes up
User enters text, and virtual keyboard closes
Press "Login"
User is logged in, and Login-window closes
I have now tried for several days to crack this