Shape Data or Context Menu? Why not both?

In Visio 2010, the Visio team added a Flyout Child cell to the Context menu of a shape.
John Goldsmith did a good write up.

Visio 2010 custom context menu

So, if you are building a Visio shape, you have two ways of controlling how a shape behaves, the context menu or by using Shape Data. With Shape Data you can set the Shape Data to a list and use a drop down to make the selection. If you are using Data Connectivity, it is nice to have the controlling information as Shape Data, but the ability to right click a shape is so convenient and tempting. So, why not use both?

So here is how I did it (with an assist from JG). To start off with, we need a few User cells. A Cell to describe the list, this is normally part of the Shape Data row, but I prefer to keep the list as a User cell. The Second is a more convenient index to the choice that was made. The Shape Data stores the choice as a string, but for most purposes, it is more convenient to have it as a number that represents the position in the list.

So, once we have the List, the next thing is the Shape Data. Type 4 is a variable list. A fixed list can also be used. Format is the List of choices, normally that would be in this cell, but as I pointed out I prefer the list as a User cell,

Now for the magic. This is similar to what John G talked about in the Custom Context Menu article, except for the SetF/GetRefs. I also prefer to use formulas for the Menu names and refer back to the List in the User cells. Any change to the list, including typos will be propagated to the Menu cells. So, fixes are easy because the information is centralized.

The trick to get this to work is in the GetRef cells. It should be a string rather than a value.
So, I needed quotes.
John G was gracious enough to point that out when I got stuck.
Thank you John. You are definitely a Visio Master.

As JohnG pointed out in his article, the FlyoutChild cells make the right click menu less cluttered. Mine is simple, but I could make it more elaborate.

David Parker, one of only a half dozen people who have recieved a Microsoft MVP award for Visio for the past decade asked why I used a User cell and why I included the title in the list. Simple, it is my stile. Over the decades, I have been burned by unintentional ungrouping by me or by people I have created shapes for. The user cells acts like a firebreak so that complex formulas are not hosed and replaced by a “Ref()” errors. So, I use a User cell within a shape and a User cell within the other shape, so rebuilding is just a matter of reestablishing the reference rather than trying to remember the complex formulas.

For those who think I had a typo, this is a stile. It is to allow people to cross your fields without worrying they will leave the gate open and your sheep/cows will wander.
— an old fashion version of a fire break.

Fence and wooden stile on green field

As to including the title in the list, it also makes it easier to support multiple languages if the title is with the list, just point the code to the list in the desired language.

I hope this helps.

John… Visio MVP in x-aisle
JohnVisioMVP.ca

Published by johnvisiomvp

The original Visio MVP. I have worked with the Visio team since 1993

One thought on “Shape Data or Context Menu? Why not both?

  1. John,

    You don’t really need the User.TypeList because the .Format cell can be referenced, and why do you have the first Action row Menu like that?
    I suggest:

    User.TypeIdx=”=LOOKUP(Prop.Type,Prop.Type.Format)”

    Action.Row_1.Action = “”
    Action.Row_1.Menu = “=Prop.Type.Label”
    Action.Row_1.FlyoutChild=”=FALSE”

    Action.Row_2.Action=”=SETF(GetRef(Prop.Type),”=INDEX(0,Prop.Type.Format))”
    Action.Row_2.Menu=”= INDEX(0,Prop.Type.Format)”
    Action.Row_2.Checked=”= User.TypeIdx=0”
    Action.Row_2.FlyoutChild=”=TRUE”

    etc

    Regards,
    David

Leave a Reply to davidjpp Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s