Add a FormulaChanged event to a shape via the ShapeAdded Event fires multiples.

Started by bwharrington, April 23, 2019, 04:24:56 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

bwharrington

As part of some advice I got from Nikolay on a post I made before this one, I'm working to move my events off the Application object and onto the Shape objects and I having some good success with this.

However, my situation is as follows.

A user can generate a stencil, this reads data from our server and creates shapes with properties as Masters on a stencil. Thats all good.

When a user drags and adds a shape from this stencil, I need to add a FormulaChanged and TextChanged event to the shape. I'm doing this through Application.ShapeAdded event.

That works great until the user changes a property on the shape. What happens is each property fires the formula changed event one time for each property, not just the changed property. This only happens the first time a property is changed on this shape. After that its one property change one event fire.

I've seen this before and have spent a reasonable amount of time trying to figure this out. Anyone experience this?

Yacine

Yacine

Lisalalinda

I am really happy to receive a good opportunity to read the content of the website that is very useful.

Nikolay

Maybe first time the properties (all of them) are changed from "No Formula" (i.e. undefined) to an empty string ("")?
In this case to avoid excessive events, you could try setting the properties to "empty string" already in the master.

bwharrington

That's a good thought and what I am doing in most cases.

That catch in this case is we have shapes from a master we create. Certain shapes have connections between each other we have in a definition. Not all shapes connect to each other/

We have to dynamically connect them using "Dynamic Connectors" and using the definition build out properties specific to this connection between the two masters.

In would be impossible/impractical and not user friendly to to have hundreds of specific dynamic connectors laying around. An unfortunately specific use case.

I have found that if I turn off shape events all the time, only only enable them when the user clicks the shape (Application.SelectionChanged) that tends to work well. And when the user does something specific I turn off all shape events for all of our shapes.

Whats odd to me is that even after all of this the trouble to unhook the shape Cell changed event, As soon as I close my dialog, my selection changed event fires, hooks up my shape.CellChanged event and runs the cell changed code.

Ive tried look for specific in SelectionChanged when the dialog closes and to filter it out, but the object is no different than when a user selects it.

If I even unhook the SelectionChanged event, as soon as I hook it back up, the selection changed event fires, hooks up the cell changed, fires the cell changed. It seems to linger in a queue of some sort that I dont understand. Something I will make a post about today.

Its only happening for one string formula field and not the other properties or shapes with the same property at the time I ask my app to create a handful of shapes and dynamic connectors.