Problem Assigning members to XRC objects
"Tim Burgess" <[email protected]> Wed, 10 Sep 2025 15:26:43 +0100
| Newsgroups | gmane.comp.lib.wxwindows.general |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I'm successfully loading an XRC file that contains subclass entries. The
relevant classes contain member variables for elements within the XRC file,
such as:
class SampleNotebookPage: public wxPanel
{
wxDECLARE_DYNAMIC_CLASS(SampleNotebookPage);
public:
SampleNotebookPage ();
// Creation
bool Create()
{
tcAttributeValue = XRCCTRL(*this, "AttributeValue", wxTextCtrl);
tcAttributeValue->Connect(wxEVT_TEXT,
wxTextEventHandler(EBrailleRequiredMetaPage::OnTextChange));
.
};
~ SampleNotebookPage ();
.
wxTextCtrl * tcAttributeVallue;
}
I successfully initialize such members when I create an instance of the
class. However, though the handlers fire correctly, trying to reference one
of my member variables within the handler leads to exceptions. Here's an
example:
void EBrailleRequiredMetaPage::OnTextChange(wxCommandEvent& event)
{
int id = event.GetId();
if (id == XRCID("tcAttributeValue"))
{
tcAttributeValue= XRCCTRL(*this, "tcAttributeValue",
wxTextCtrl);
// Assertion here:
if (tcAttributeValue->GetValue().Trim().IsEmpty())
{
.
}
else
{
.
}
}
}
If I try to access the member directly:
tcTitle->GetValue();
I get an exception.
What am I missing here, as I thought I was following all of the examples
I've found.
Many thanks in advance.
Tim
--
Please read https://www.wxwidgets.org/support/mlhowto.htm before posting.
---
You received this message because you are subscribed to the Google Groups "wx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/wx-users/008f01dc225e%24eef3fd70%24ccdbf850%24%40raisedbar.net.