working entry dialogue made with the help of practically nonexistent documentation

This commit is contained in:
Lynne Megido 2020-08-29 02:58:14 +10:00
parent d6bf37da44
commit aef8ef0bbd
Signed by: lynnesbian
GPG key ID: F0A184B5213D9F90

View file

@ -15,10 +15,33 @@ namespace Buypeeb {
Application.Quit();
}
// convenience functions
private (Boolean accepted, string response) EntryDialogue(string title = "Buypeeb", string message = "Hi there!") {
Dialog ed = new Dialog(title, null, Gtk.DialogFlags.DestroyWithParent, "Cancel", ResponseType.Cancel, "OK", ResponseType.Ok);
Label edLabel = new Label(message);
Entry edEntry = new Entry();
ed.ContentArea.PackStart(edLabel, true, true, 2);
edLabel.Show();
ed.ContentArea.PackStart(edEntry, true, true, 10);
edEntry.Show();
// TODO: pressing enter should submit the form
ResponseType accepted = (ResponseType)ed.Run();
string response = edEntry.Text;
ed.Destroy();
return (accepted == ResponseType.Ok, response);
}
// button handlers
private void ButtonAddClicked(object sender, EventArgs a) {
Console.WriteLine("ButtonAddClicked");
var EntryResponse = EntryDialogue();
Console.WriteLine(EntryResponse.response);
}
private void ButtonUpdateAllClicked(object sender, EventArgs a) {