How do I link the input on textbox content to label and put it on screen? Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
cymotrichous
In need of some credit
In need of some credit
Posts: 3
Joined: Sat Oct 14, 2017 10:40 am

How do I link the input on textbox content to label and put it on screen?

Post by cymotrichous »

Hello, Im creating a simple GUI on codeblocks using wxWidgets and Im struggling to this.
How would you link the signal sent by clicking the button, to another function that puts the textbox contents into a label, and puts it on the screen?
Like for example; INPUT: TEST -> Clicking "OK" button would result as an output: Hello Test! Any help is much appreciated! Thank you!
jgrzybowski
Earned some good credits
Earned some good credits
Posts: 113
Joined: Sat Sep 24, 2011 9:32 pm
Location: Poland

Re: How do I link the input on textbox content to label and put it on screen?

Post by jgrzybowski »

You should define EVT_BUTTON, examples are in docs and some simple below:

Code: Select all

//...
BEGIN_EVENT_TABLE(Your_App_Frame_Frm,wxFrame)
	//...
	EVT_CLOSE(Your_App_Frame_Frm::OnClose)
	//...
	EVT_BUTTON(ID_YOURBUTTON,Your_App_Frame_Frm::buttonYourButtonClick)
	//...
END_EVENT_TABLE()
//...
/*
 * buttonYourButtonClick
 */
void Your_App_Frame_Frm::buttonYourButtonClick(wxCommandEvent& event)
{
    //here your code for copying text from textbox into label;
    return;
}
Similar topic: viewtopic.php?f=1&t=43132&p=175479&hili ... ON#p175479
Regards, Jarek
cymotrichous
In need of some credit
In need of some credit
Posts: 3
Joined: Sat Oct 14, 2017 10:40 am

Re: How do I link the input on textbox content to label and put it on screen?

Post by cymotrichous »

jgrzybowski wrote:You should define EVT_BUTTON, examples are in docs and some simple below:

Code: Select all

//...
BEGIN_EVENT_TABLE(Your_App_Frame_Frm,wxFrame)
	//...
	EVT_CLOSE(Your_App_Frame_Frm::OnClose)
	//...
	EVT_BUTTON(ID_YOURBUTTON,Your_App_Frame_Frm::buttonYourButtonClick)
	//...
END_EVENT_TABLE()
//...
/*
 * buttonYourButtonClick
 */
void Your_App_Frame_Frm::buttonYourButtonClick(wxCommandEvent& event)
{
    //here your code for copying text from textbox into label;
    return;
}
Similar topic: viewtopic.php?f=1&t=43132&p=175479&hili ... ON#p175479
Regards, Jarek

Code: Select all


I have this code below, how do I link the input on text box after clicking the OK button? It should display as, "Hello World! *[i]user input[/i]*". Any help is appreciated!
[code]void HWFrame::OnAbout(wxCommandEvent& event)
{
    wxString msg = wxbuildinfo(long_f);
    wxMessageBox(msg, _("Welcome to..."));
}

void HWFrame::OnButton1Click(wxCommandEvent& event)
{
    wxString msg= _T("Hello World!");
    wxString info= _T("MESSAGE");
    wxMessageBox(msg,
                info,
                wxOK | wxICON_INFORMATION,
                this);
}

void HWFrame::OnTextCtrl1Text(wxCommandEvent& event)
{

}
[/code]
jgrzybowski
Earned some good credits
Earned some good credits
Posts: 113
Joined: Sat Sep 24, 2011 9:32 pm
Location: Poland

Re: How do I link the input on textbox content to label and put it on screen?

Post by jgrzybowski »

You can just copy value from your text box inside of click button function:
info=TextCtrl1->GetValue();
Regards, jarek
Post Reply