Jump to content
  • Advertisement
Sign in to follow this  
paic

[.net] Nested properties and notification

This topic is 3664 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I've got another question about .NET, this time regarding properties :) I'd like to create a property on top of a D3DXVECTOR3 (or any other class with public members) For the moment, I'm using something like :
[TypeConverterAttribute(ExpandableObjectConverter::typeid)]
ref class Vector3
{
    public:

        Vector3(const D3DXVECTOR3 & vector) :
            m_Vector(new D3DXVECTOR3(vector))
        { }

        // a few other constructors here

        ~Vector3(void)
        {
            delete m_Vector;
        }

        [NotifyParentPropertyAttribute(true)]
        property float x
        {
            float get(void) { return(m_Vector->x); }
            void set(float value) { m_Vector->x = value; }
        }

        // same thing for y and z properties

        virtual String ^ ToString(void) override
        {
            return("" + m_Vector->x + ";  " + m_Vector->y + ";  " + m_Vector->z);
        }

    private:

        D3DXVECTOR3 *   m_Vector;

};

Now, I have something like that in another class :
public:

    property Vector3 ^ AVector
    {
        Vector3 ^ get(void) { /* Do something ... */ }
        void set(Vector3 ^ value) { /* Do something ... */ }
    }
When I set an instance of this class in a PropertyGrid, the property is correctly displayed, I can expand it to edit the members (x, y or z) But when I change one of these values, the "set" method of AVector is not called ! How should I do ? I thought that was what [NotifyParentPropertyAttribute(true)] is for ... Is it possible to make the Vector3 property call its set method when one of its member was changed ? Thx for any help :)

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!