Populating smart shape comment field with menu selection text

Started by John Distai, March 10, 2014, 04:05:21 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

John Distai

Hi,

I have a smart shape that has 10 states.  In the action menu, the states have labels such as "Enabled", "Disabled", etc.  I select the state by right clicking on the shape and selecting it from the menu.

What I'd like to do is populate the "Miscellaneous > Comment" cell in the shape sheet with the menu entry for the current selection.  So if my shape is set to "Enabled", then when I hover over it "Enabled" is shown.  I'd like this label to change based on the state selection.

Does anyone know how I would do this?  I thought about a setf(getref...) statement in each action line, but I'm not sure how to reference the "Comment" line and get it to match up with the menu name of the currently selected item (or I could hard code it in the statement).

Any help is appreciated!

Yacine

To find a fields address in the shapesheet, you just need to edit a user or custom field and while in editing mode click the desired field.
You'll find out, the comment field is just named "comment"  ;)

And I agree with you, setf(getref( should be the way to go.

Regards, Y.
Yacine

JohnGoldsmith

Hello John,

My approach would be to have an intermediate cell (User.StateIdx in the attached image) to keep track of the index.  The comment cell could then use this index to look up the actual value in Shape Data format cell.  It doesn't have to be in Shape Data, but generally this makes sense.

Hope that helps.

Best regards

John
John Goldsmith - Visio MVP
http://visualsignals.typepad.co.uk/

Jumpy

Hi John,

would be nice, if one could see the Checked column of the Action rows, too, as I guess there're interesting formulas, too?

John Distai

Thanks.  I'm not using the Index stuff.  I haven't figured out how to do that yet.  :(

JohnGoldsmith

Hello John,

Now's a great time to master it!  The indexing really just relies on two ShapeSheet functions: LOOKUP and INDEX.   Index is given to you automatically when you use a fixed list in the Shape Data 'Type' cell.  Under this circumstance, Visio adds an Index function to the value cell and finds a particular index (0=first item, 1=second and so on) in the 'list' that you provide in the Shape Data 'Format' cell.  I've then added a user cell (User.StateIdx, nothing special about the name...it could be called anything you like) to keep a record of the currently selected list (remember the format cell) item. 

The rationale for the User cell is that you can keep the lookup in one place rather than doing it in every cell where you need to know the current state.  Also, you get to keep one place for your options list.  If you need to change the list items in the future, say to "Chilly;Clement;Roasting", then all of your menu items would update too as they use an Index function as well.  If you want to extend your list later on you're free to do so as long as you existing items retain their functional meaning.

The Actions cells just push a respective index formula into the Shape Data cell as this is the cell that everything hinges on.

@Jumpy - are you getting all of the image?  In my view the checked column is visible.  Does that work for you?  If you can't, the formula are as follows:

Actions.Row_1.Checked    User.StateIdx=0

Actions.Row_2.Checked    User.StateIdx=1

Actions.Row_3.Checked    User.StateIdx=2


This highlights how pushing off the state to another cell can simplify all of the other dependent cells.  Of course if you're looking at that cell you've got to remember that, for example, 'Hot' is index 2, but with a short list of options I think that's ok.  I looked at an alternative in this post:http://visualsignals.typepad.co.uk/vislog/2013/03/using-bitwise-functions-in-visio-part-2.html

Does that help?

Best regards

John


John Goldsmith - Visio MVP
http://visualsignals.typepad.co.uk/

Jumpy

Quote from: JohnGoldsmith on March 11, 2014, 09:43:06 PM
@Jumpy - are you getting all of the image?  In my view the checked column is visible.  Does that work for you?  If you can't, the formula are as follows:

I swear: Yesterday, when looking at  the picture, there was no Scrollbar. Now there is one and I could scroll to the right to see the "Checked" Column. Ok, maybe I just was to tired to see it  ;D

Your whole approach is quite elegant I think. I did nearly the same, some way back, but in a really clumsy way:
In the Action I used SETF to check the action and uncheck all the others:
=SETF(GetrRef(Actions.Row_1.Checked ),True)+SETF(GetrRef(Actions.Row_2.Checked ),False)+SETF(GetrRef(Actions.Row_3.Checked ),False)

and in a userdefinded cell, I reactetd to that:
=If(Actions.Row_1.Checked,Do sth.,If(Actions.Row_2.Checked,Do other sth.,If(Actions.Row_3.Checked,Do sth. other,Do nothing)))

It worked OK, but it's not elegant.

JohnGoldsmith

Yes, I guess you can go in either direction, also if you have a range of non-mutually exclusive options then it becomes more tricky.  Generally I prefer to keep as much of the logic in the User/Shape Data sections.  It means that you can see all of the logic in one place and the dependent cells don't have to be concerned with that side of things.  For example, the visibility of a sub-shape or geometry section only needs to know whether it should be visible or not.  I think there are caveats to that approach, one of the main ones being how modular you want you shapes to be, ie do you need to add and remove certain functionality for different situations.

Anyway, there's always more than one way to skin the Visio cat :)

Best regards

John
John Goldsmith - Visio MVP
http://visualsignals.typepad.co.uk/

vojo

so as a side bar, you can also do sequenced drop downs if you want  (sort of a poor mans shape GUI)

Create several action rows  (the usual setf(getref(<checked>), if(<checkec>,0,1)
Create a user cell (user.index
Create a user cell
   (something like  If(<checked1>, user.index = user.index+1,user.index = user.index-1 ) + if(<checked2>, blah blah +2, -2) + +4, -4)
On props rows, for hidden cells, have them check  (if(user.index >1,0,1)....or...if(user.index >2,0,1)
Create another user cell (something like if(user.index > 0, docmd(1312),)

So now you can go into actions....select the catagories of props you want to see...and that subset comes up

May need to play with this some....I did this for blades about 5 years ago so memory might be a bit off.