From aef8ef0bbdf4d352156b917638612c93271514f7 Mon Sep 17 00:00:00 2001 From: Lynnesbian Date: Sat, 29 Aug 2020 02:58:14 +1000 Subject: [PATCH] working entry dialogue made with the help of practically nonexistent documentation --- MainWindow.cs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/MainWindow.cs b/MainWindow.cs index 8dd1ccf..ab7edbe 100644 --- a/MainWindow.cs +++ b/MainWindow.cs @@ -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) {