1. EuGTK:Working Demo For Pop-up Dialog to Collect A String
- Posted by euphoric (admin) Sep 23, 2019
- 1055 views
Irv, is there a working demo of popping up a dialog to capture string input from the user? I don't know whether to build my own dialog for that or customize a built-in one.
I'm having a user click a "Create New Project" button on an opening dialog, and I want to pop up a modal dialog box to capture the name of the project first. How do you recommend doing that?
Here's the dialog I'm trying to use: can I get the value in txt_newProjectName returned to me? Should I just use "add" to customize a built-in dialog box?
If I use my dialog, do I need to write a function to capture the string when the user clicks "Create," or will it act as a function and return that value to me?
constant winNewProject = create(GtkWindow,"title=`New Project`,size=400x200,border_width=8,position=1"), panel_NewProject = create(GtkBox,VERTICAL), panel_NewProjectName = create(GtkBox,HORIZONTAL), panel_NewProjectButtons = create(GtkBox,HORIZONTAL), lbl_newProjectName = create(GtkLabel,"New Project Name"), txt_newProjectName = create(GtkEntry,{ {"margin top",10}, {"margin_bottom",10}, {"placeholder text","Name your new project"} }), bttn_NewProjectCreate = create(GtkButton,"Create"), bttn_NewProjectCancel = create(GtkButton,"Cancel") pack(panel_NewProjectName, {lbl_newProjectName, txt_newProjectName}) pack(panel_NewProjectButtons, {bttn_NewProjectCreate,bttn_NewProjectCancel}) pack(panel_NewProject,{panel_NewProjectName,panel_NewProjectButtons}) add(winNewProject,panel_NewProject)
2. Re: EuGTK:Working Demo For Pop-up Dialog to Collect A String
- Posted by irv Sep 23, 2019
- 1034 views
There are several ways to do what you want. Perhaps the simplest is demonstrated here:
https://openeuphoria.org/pastey/322.wc
It uses a standard dialog with an addon GtkEntry. Since clicking on either dialog button closes and destroys the dialog (and all items it contains), the entry is destroyed before you can get the contents.
The trick is to capture the "about to be destroyed" event on the entry, which is the "unrealize" signal, and connect it to a routine which saves the entry text before it all goes away.
Then we use the OK or Cancel signals from the dialog to decide whether to update a variable with the new contents or to retain the old value.
3. Re: EuGTK:Working Demo For Pop-up Dialog to Collect A String
- Posted by euphoric (admin) Sep 23, 2019
- 1031 views
Thank you for the example!
4. Re: EuGTK:Working Demo For Pop-up Dialog to Collect A String
- Posted by euphoric (admin) Sep 23, 2019
- 1021 views
Can you show me the same example with custom buttons on the pop-up dialog box ("Create" and "Cancel")?
5. Re: EuGTK:Working Demo For Pop-up Dialog to Collect A String
- Posted by euphoric (admin) Sep 23, 2019
- 1011 views
Can you show me the same example with custom buttons on the pop-up dialog box ("Create" and "Cancel")?
I think I got what I need. I had to be closing the dialog myself if I was using custom buttons.