wxPropertyGrid problem 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
Domino
In need of some credit
In need of some credit
Posts: 6
Joined: Wed Jan 03, 2007 2:43 pm

wxPropertyGrid problem

Post by Domino »

Hi all,

I have stupid (I hope) problem with wxPropertyGrid. Let's say I have properties:

Code: Select all

// pProped is a wxPropertyGrid pointer
wxPGId catID = pProped->AppendCategory("Category");
wxPGId parentID = pProped->AppendIn(categoryId, wxParentProperty("Pivot", wxPG_LABEL));
pProped->AppendIn(parentID, wxFloatProperty(wxT("x"), wxPG_LABEL, value.x));
pProped->AppendIn(parentID, wxFloatProperty(wxT("y"), wxPG_LABEL, value.y));
pProped->AppendIn(parentID, wxFloatProperty(wxT("z"), wxPG_LABEL, value.z));
parentID = pProped->AppendIn(categoryId, wxParentProperty("Position", wxPG_LABEL));
pProped->AppendIn(parentID, wxFloatProperty(wxT("x"), wxPG_LABEL, value.x));
pProped->AppendIn(parentID, wxFloatProperty(wxT("y"), wxPG_LABEL, value.y));
pProped->AppendIn(parentID, wxFloatProperty(wxT("z"), wxPG_LABEL, value.z));
pProped->DisableProperty("Pivot");
now in my code values in first property should be changed when second property values changes. So I wrote the code that fill Pivot with proper values if Center changes. The problem is that Pivot property is not refreshed after changing values and old values stays (for both child properties and parent property). I call pProped->Refresh(). I also tried

Code: Select all

pProped->PropertyWasModified(xID);
pProped->PropertyWasModified(yID);
pProped->PropertyWasModified(zID);
// where xID, yID, zID are wxPGId of "x", "y", and "z" properties of Pivot
(...)
pProped->Reftesh();
pProped->ClearModifiedStatus();
but it causes an error (application crashes). I also tried to set

Code: Select all

pProped->PropertyWasModified("Pivot");
but it also causes an error. I also tried not to disable Pivot property but it doesn't help.
Anyone know how to deal with this issue?
jms
Experienced Solver
Experienced Solver
Posts: 54
Joined: Wed Sep 29, 2004 6:37 am
Location: Finland

Post by jms »

Something like this (in the EVT_PG_CHANGED handler) worked for me (assuming that by Center you actually meant Position):

Code: Select all

    wxPGId id = event.GetProperty();
    if ( pProped->GetPropertyName(id) == wxT("Position") ||
        pProped->GetPropertyName(pProped->GetPropertyParent(id)) == wxT("Position") )
    {
        pProped->SetPropertyValue(wxT("Pivot"), wxT("10; 10; 10"));
    }
Domino
In need of some credit
In need of some credit
Posts: 6
Joined: Wed Jan 03, 2007 2:43 pm

Post by Domino »

jms wrote:Something like this (in the EVT_PG_CHANGED handler) worked for me (assuming that by Center you actually meant Position):

Code: Select all

    wxPGId id = event.GetProperty();
    if ( pProped->GetPropertyName(id) == wxT("Position") ||
        pProped->GetPropertyName(pProped->GetPropertyParent(id)) == wxT("Position") )
    {
        pProped->SetPropertyValue(wxT("Pivot"), wxT("10; 10; 10"));
    }
Heh, in my code I change values of child properties (x, y and z of Pivot) in the EVT_PG_CHANGED handler and not the parent property. Child properties are refreshed properly (I made a mistake in previous post) but the parent isn't until it get's focus or I collapse some other parent property.
jms
Experienced Solver
Experienced Solver
Posts: 54
Joined: Wed Sep 29, 2004 6:37 am
Location: Finland

Post by jms »

Ok, I have now changed SetPropertyValue to refresh parent as well. Try the latest development snapshot.
Domino
In need of some credit
In need of some credit
Posts: 6
Joined: Wed Jan 03, 2007 2:43 pm

Post by Domino »

jms wrote:Ok, I have now changed SetPropertyValue to refresh parent as well. Try the latest development snapshot.
Thanks, now it works fine.
Post Reply