Visio Guy

Visio Discussions => Programming & Code => Topic started by: healthNut on November 25, 2012, 08:03:13 PM

Title: Would appreciate help resolving unexpected duplicated function calls first event
Post by: healthNut on November 25, 2012, 08:03:13 PM
The Problem:
When my shape is dropped on a page, the first time I change the shape's data from previousOption to newOption, it seems to fire two events:
1) Event 1 with previousOption
2) Event 2 with newOption

Desired fix:
Shape data changes fires only one Event with newOption

The setup: Shapesheet
*Shape Data: list of options
*User-Defined Cells: DEPENDSON(Prop.data) + CALLTHIS( "CodeModule.FooFunction", "CodeFile", Option  )

The QA:
Debug.print in Foo shows

*On first shape data change:
-Foo( Previous Option )
-Foo( New Option )

*On subsequent changes:
-Foo( new Option)
Title: Re: Would appreciate help resolving unexpected duplicated function calls first event
Post by: Jumpy on November 26, 2012, 07:59:06 AM
If you drop the new shape: Does this automatically trigger the ShapeDataDialog? Than you make the first change, hit OK, and your function get's triggered two times?

The question is why Visio thinks Prop.data is changed, when a shape is only dropped on the page. The value should be the original value in the mastershape, or not?

Maybe add a user cell User.FirstTrigger with value false. OnDrop-Event set the value to true. In code look if value true or false and react accordingly. Problem with that can be order in which Visio handles events.
Title: Re: Would appreciate help resolving unexpected duplicated function calls first event
Post by: healthNut on November 27, 2012, 01:17:28 AM
Quote from: Jumpy on November 26, 2012, 07:59:06 AM
If you drop the new shape: Does this automatically trigger the ShapeDataDialog?
No, I don't force user to use a dialog box.
However it does fire events multiple times, not even just 2, but 4 or so times on the shape being dropped.
Furthermore, it fires incomplete calls. I traced the functions that are being called and they are either being partially called or the debug messages are not going to the immediate window

Quote from: Jumpy on November 26, 2012, 07:59:06 AM
Than you make the first change, hit OK, and your function get's triggered two times?
Yes

Quote from: Jumpy on November 26, 2012, 07:59:06 AM
The question is why Visio thinks Prop.data is changed, when a shape is only dropped on the page. The value should be the original value in the mastershape, or not?
Yes I would of thought there should be no events being fired if there is no data change and there lies my problem.

Quote from: Jumpy on November 26, 2012, 07:59:06 AM
Maybe add a user cell User.FirstTrigger with value false. OnDrop-Event set the value to true. In code look if value true or false and react accordingly. Problem with that can be order in which Visio handles events.
Great idea! I will try that. This could also be a situation where I offload the code handling to formulas too.

Thanks again for your help, I look forward to when I can return it.
Browser ID: smf (is_webkit)
Templates: 1: Printpage (default).
Sub templates: 4: init, print_above, main, print_below.
Language files: 1: index+Modifications.english (default).
Style sheets: 0: .
Hooks called: 46 (show)
Files included: 25 - 925KB. (show)
Memory used: 773KB.
Tokens: post-login.
Cache hits: 6: 0.00082s for 22,291 bytes (show)
Cache misses: 1: (show)
Queries used: 8.

[Show Queries]