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!
How do I link the input on textbox content to label and put it on screen? Topic is solved
-
- In need of some credit
- Posts: 3
- Joined: Sat Oct 14, 2017 10:40 am
-
- 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?
You should define EVT_BUTTON, examples are in docs and some simple below:
Similar topic: viewtopic.php?f=1&t=43132&p=175479&hili ... ON#p175479
Regards, Jarek
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;
}
Regards, Jarek
-
- 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?
jgrzybowski wrote:You should define EVT_BUTTON, examples are in docs and some simple below:Similar topic: viewtopic.php?f=1&t=43132&p=175479&hili ... ON#p175479Code: 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; }
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)
{
}
-
- 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?
You can just copy value from your text box inside of click button function:
info=TextCtrl1->GetValue();
Regards, jarek
info=TextCtrl1->GetValue();
Regards, jarek