Right-Mouse Action to show one layer, hide others?

Started by clockeby, April 14, 2014, 07:07:49 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

clockeby

Hello!

I'm working on a Stencil for our User Experience team for easier creation of website wireframes. We are currently using Visio 2007 and I'm fairly comfortable with Visio itself, but the Shapesheet formulas are new to me. I've done some basics with changing text color, hide/show an element using right-mouse actions but this issue is proving a bit more challenging.

I have a menu shape consisting of a menu bar with six tabs. Within this shape I have six more shapes acting as the "active" state for each menu tab. The main menu bar shape is on its own layer, as are each "active" tab, seven layers total. I'd like to create a right-mouse action that allows designers to set which tab is active. The options would be "Set Home Active, Set Products Active", etc. with an option for each one of the six.

The action formula itself would need to set all other layers as not visible and not printable, excluding the menu layer. So when you set home active, the menu bar would show, as well as the "active state" layer for home, while all other active state tabs would be hidden. When you set products active, the menu bar and the products active state tab would show, while all other active state tabs would be hidden. You get the idea.

I'm thinking Home would be the default active tab and the action formula itself would be attached to the main shape consisting of all the other grouped shapes. I was looking at this article http://www.visguy.com/2006/09/05/the-hidden-world-of-visio-shapes/ which I'd used for helping with simple on/off toggles, but how do I show one layer while hiding the five others? All of my guesses either give me an error or have no effect.

Any help you guys can give me would be greatly appreciated. This is the last shape in my stencil set before I had it off to the rest of the team so I'm pretty excited to be wrapping it up. I think it'll make wireframing a mockup of changes or new pages much more efficient.


clockeby


clockeby

Thanks again for the response, Yacine.

The first link you listed is the same one I referenced in my original question. Yes, that works great for a toggle, which would be perfect if I wanted to randomly have layers on (visible) or off. What I'm looking for is a bit different. I don't want the possibility of two "active state" layers visible at once. I don't want to set multiple states manually. I'm looking for more of a "IF(Any.Sub.Layer=TRUE) THEN(Other.Sub.Layers=FALSE)" formula.

The second link I don't get. The images included on the page aren't showing for me and I'm not sure where/how to type pages of VB code. I come from a graphic design/user interface background so a lot of this is foreign. I'm doing pretty well with basic formulas (toggle layers/shapes, etc.) but was having trouble with how to make "IF(Any.Sub.Layer=TRUE) THEN(Other.Sub.Layers=FALSE)" happen.

I suppose I could just add a toggle action for each layer and manually set them on or off as needed. I just hoped there was an an easier way.

Yacine

#4
Please find enclosed a solution, which if not elegant works neverthless.
The big disadvantage is that the layers are hard coded.
It is based on one central control shape which has all the logic included.
The formulas could of course be written in the shapesheet of the page itself.
Hope that helps anyway,
Y.
Yacine

clockeby

That's great timing and oddly coincidental. I was just attempting a solution based on the Visio SmartFace post here: http://www.visguy.com/2011/04/07/visio-smartface/

It has similarities to the formulas you show in your attachment but I was struggling with how to apply the layers model to the formulas used in it.

I'll rewind and try this. I appreciate your help!

clockeby

Okay, after a delay from other projects, I'm back to this. Thank for the code, I was able to input what you attached with no errors, but the results aren't quite there yet. I think some minor tweaks should finish it but again, I'm getting "Error in formula" messages when I try to find an answer.

My User.Layer0 is the main menu bar. The problem I'm having is, that layer needs to show at all times, no matter what other layer is set as visible.

User.setVisible=SETF(GetRef(ThePage!Layers.Visible),User.Layer0)+SETF(GetRef(ThePage!Layers.Visible[2]),User.Layer1)+SETF(GetRef(ThePage!Layers.Visible[3]),User.Layer2)+SETF(GetRef(ThePage!Layers.Visible[4]),User.Layer3)+SETF(GetRef(ThePage!Layers.Visible[5]),User.Layer4)+SETF(GetRef(ThePage!Layers.Visible[6]),User.Layer5)+SETF(GetRef(ThePage!Layers.Visible[7]),User.Layer6)

In the above code, setting the shape data for any other User.LayerX only shows that layer (the active state for the menu link) and NOT the main menu bar itself. So basically I get a "highlighted" tab floating in space with nothing behind it. I tried adding:
SETF(GetRef(ThePage!Layers.Visible),User.Layer0,User.Layer1)
SETF(GetRef(ThePage!Layers.Visible),User.Layer0,1)
SETF(GetRef(ThePage!Layers.Visible),User.Layer0;User.Layer1)

So apparently I'm not getting the syntax but my goal is when I set any single layer as visible, show User.Layer0 as well.

wapperdude

For your application, toggling on/off is not the most efficient approach.  Basically, you are wanting to enable one layer and turn the others off.  That's not toggling.

First, since your "header" layer is always visible, it doesn't need any action at all, just set it to be visible.  (Unless I mis-understood).

Then in the actions section, you want to set the actions to view the selected layer and turn the others off by catenating the commands.  In addition, you might want to set the check marks so it's "menu obvious" which is selected.

I'm attaching a simple file used for another development, but basically does what you'd like.  Check the actions section.  It will, at least, give you the necessary form.  You could bypass the User section, or keep it.  If you decide to keep it, then the action section would merely set the desired layer to visible.  The user rows would use an if function plus or function could be used in each user row to see if any of the other layers are set to visible.  If so, then, use that row to set it's layer to be non-visible. 

For example, if action sets layer1 visible, then user.layer1 would do nothing, but, all other user.layers would set their layers to non-visible.

HTH
Wapperdude
Visio 2019 Pro

halina

#8
@wapperdude

Hi, I'm trying to do something very similar where I can switch one layer on and all others off. I'm very new to Visio and am having a hard time following your example, I was wondering if you could help me understand where I'm going wrong?

=IF(Layers.Visible[3]=1,SETF(GetRef(Layers.Visible[3]),1)+SETF(GetRef(Layers.Visible[2]),0)+SETF(GetRef(Layers.Visible[4]),0)+SETF(GetRef(Layers.Visible[5]),0)+SETF(GetRef(Layers.Visible[6]),0),SETF(GetRef(Layers.Visible[3]),1)+SETF(GetRef(Layers.Visible[2]),1)+SETF(GetRef(Layers.Visible[4]),1)+SETF(GetRef(Layers.Visible[5]),1)+SETF(GetRef(Layers.Visible[6]),1))

wapperdude

Is it just one, specific layer, when on, the others are off, or is it you want only one layer at at time, regardless of which layer it might be?

Visio 2019 Pro

wapperdude

Couple things, the IF statement would have to be more complex than it is to work as a simple toggle.  Oxymoron, nothing simple about it!  There's an error, Layer3 is set to visible for both cases.

Long constructions, especially for IF statement logic, get to be unwieldy, and confusing over time.  It's better to break into "true" & "false" collections for understandability.  Perhaps not the most efficient from code structure.  Also, makes trouble-shooting easier.

The other thing to note, layers are property of the page, and assigned to the shapes on that page.  So, just beware when migrating to other pages.  I created simple example, that always leaves layer1 on, toggles layer 3 on/off, and all other layers off/on.  This is executed by right clicking anywhere in the page and selecting the Action response.  The "coding" takes place in the page's shapesheet.

I added a User Defined section and an Action Section.  The User Defined has two rows.  First row is "true" collection, i.e., show only layer3.  Second row is "false" collection to hide layer3.  The two collections check the status of the Action entry.  Function of each collection is reasonably obvious for someone to understand 6 months or whatever down the road.  Each is easily modified.

HTH
Wapperdude
Visio 2019 Pro

vojo

wingnut from left field

Action 1 = setf(getref(action 1.checked), if (action 1.checked =1,0,1))
action 2
action 3

User.layer1 = if (action1.checked, setf(getref(layers.visibile[1]),1,setf(getref(layers.visible[1], 0))
user.layer2
user.layer3

This way, upon right click,  1 or more layers can be made visible or invisible.   Either way, user feedback

just a wingnuts idea

vojo

might be kind of interesting at a group level

Might a group of shapes ...child shapes on different layers

so maybe want to show that groups layer stuff.

wapperdude

#13
"Wingnut" ???   Not really.  It's a further step in reducing formula complexity.  It has advantage of seeing how each layer is being controlled, and easily adaptable foe additional controls on a per layer basis.  Obviously a little more initial setup time, but good benefits. 

Oh, I think user.layer1 has unintentional missing ")":

is: if (action1.checked, setf(getref(layers.visibile[1]),1,setf(getref(layers.visible[1], 0))
s/b: if (action1.checked, setf(getref(layers.visibile[1]),1),setf(getref(layers.visible[1], 0))

Visio 2019 Pro

halina

Thank you @wapperdude @vojo. My intention for setting layer 3 visible for both classes was to have the ability to set either 1 layer visible or all layers visible. Your example was super helpful, I really appreciate it.