code::blocks and wxSmith

My issue is that I have a Button set on a page. Default is "No". Simply put, all I want is for the button to alternate between "Yes" and "No" when clicked. The problem is that nothing changes. The button displays "No" even after clicked. This is what I have:

if (Button1->GetLabel() == (_("No")))
{
Button1->SetLabel(_("Yes"));
}
else
{
Button1->SetLabel(_("No"));
}

I'm new to this and would appreciate help. Thank you.
Last edited on
if you can set the label with SetLabel() function maybe you can get it with GetLabel() or just Label(). cant help more sarry.
Did you try

if (Button1->GetLabel == "Yes")

or

if (Button1->GetLabel() == "Yes")

Andy

http://docs.wxwidgets.org/stable/wx_wxbutton.html#wxbuttongetlabel

wxButton::GetLabel

wxString GetLabel() const

Returns the string label for the button.


And it would prob be better to use the same _() macro with operator== as you're using with the SetLabel() method
Last edited on
Thank you, Andy. I made a couple changes, including keeping the macro the same. And then I worked with the IDE and found something that I'd missed doing. It seems there's an event handler in the wxSmith's properties window that has to be set for the events requested. I thought coding wld be enough. But w/out setting an event for the button in the event handler window, my code (though error-free) did nothing. I like this =) But I'll be back. I'm certain I'll have more questions for this forum. 100% so.
Last edited on
Topic archived. No new replies allowed.