Visio Guy

Visio Discussions => ShapeSheet & Smart Shapes => Topic started by: Visisthebest on February 11, 2020, 05:38:28 PM

Title: EventDblClick = OPENTEXTWIN() but then for the text of a subshape
Post by: Visisthebest on February 11, 2020, 05:38:28 PM
Can the EventDblClick for a group shape be set so that the users edits the text of a specific subshape we specify in the shapesheet?

Kind of like EventDblClick = OPENTEXTWIN() but then for the text of a subshape.

Thank you for your help!
Title: Re: EventDblClick = OPENTEXTWIN() but then for the text of a subshape
Post by: Yacine on February 11, 2020, 05:54:20 PM
Not as specific as you want, but if you protect the group against text editing, then the first shape in the depth order of the group gets its text edited when pressing F2 (text edit). Not sure if the double click works as well.
Title: Re: EventDblClick = OPENTEXTWIN() but then for the text of a subshape
Post by: Visisthebest on February 11, 2020, 06:05:47 PM
Thank you Yacine that is already better than how it currently works!

Is it possible to open user editing of text on a (sub)shape with a macro? Then I could activate the macro when the group is double-clicked!
Title: Re: EventDblClick = OPENTEXTWIN() but then for the text of a subshape
Post by: Visisthebest on February 11, 2020, 06:12:17 PM
Turned on protection of the group text then getting this message when clicking the group and then F2:
Shape protection, container and/or layer properties prevent complete execution of this command.

Selecting the specific subshape and pressing F2 does still work properly.

Using Visio 2019.

Title: Re: EventDblClick = OPENTEXTWIN() but then for the text of a subshape
Post by: Visisthebest on February 11, 2020, 06:16:30 PM
Just making the subshape the frontmost shape seems to have done the trick though, no text protection on the group needed!
Title: Re: EventDblClick = OPENTEXTWIN() but then for the text of a subshape
Post by: vojo on February 11, 2020, 06:28:26 PM
since shapes grouped (shape relationship predefined), you can do something different

overview
- at group level, add controls to manage group shape properties
    - props.A for <for child shape A>
    - props.B fpr <for child shape B>
- use this to set text for each child  (group doubleclk = docmd(1312) or standard shape props window)
- then have each child shape pick the right value from group
    - use the fields function in each child shape to show its respective text.

Perhaps a simpler approach would be to go to behavior and set "show child shapes first" on the lower right of the menu
This would allow you to double click the child shape of interest.   From there you can use props  (docmd(1312) in eventdblclk)
or child shape data window to get user data into the shape....then either show the shape data on its screen or use fields to show in shape

The key problem with what you are trying to do is that the child shape has to be selected and double click to execute
Unless you want to write some VBA to achieve your results.
Title: Re: EventDblClick = OPENTEXTWIN() but then for the text of a subshape
Post by: Visisthebest on February 11, 2020, 06:47:48 PM
Thank you Vojo! Unfortunately it will typically be multi-line text for which the shape data editor window isn't great being single line. How do you think I could solve it in VBA?

What you propose above is a great solution for another shape I'm working on though!
Title: Re: EventDblClick = OPENTEXTWIN() but then for the text of a subshape
Post by: vojo on February 11, 2020, 07:56:18 PM
I don't do much with VBA because the user has to set up his system to support

That said
- need to find the group on the page then find the shape in the group
- need to build a GUI or forms to get data
- need to place data in the shape

I think VBA will be over kill and be a security issue roadblock

May be could look at containers in visio....maybe a container of shapes where you can edit each shape directly
Title: Re: EventDblClick = OPENTEXTWIN() but then for the text of a subshape
Post by: Visisthebest on February 12, 2020, 12:55:25 AM
Yes that becomes too complicated as well, maybe I should be using the group text and then align this text with the subshape I want this text to be shown on (disabling the text on the subshape itself). Bit of a workaround too though, but good to know there is some compromise necessary for this to work.

For the security issues putting a code signing certificate on the vba helps to mitigate that issue.

Thank you for your help and advice Vojo!
Title: Re: EventDblClick = OPENTEXTWIN() but then for the text of a subshape
Post by: vojo on February 12, 2020, 02:01:02 AM
RE certificate, sure...but only half the problem
Need to enable the VBA engine as well as VBA projects.  On excel projects I have done, those were beyond certificate stuff

Also, you cant guarantee all users have certificates....can you? 
They would have to change their security settings to allow VBA as well...at least had to do that for Excel

RE multiline:  You may want to play around to see if truly a problem (wrapping a long string, multiple prop fields, etc)
Title: Re: EventDblClick = OPENTEXTWIN() but then for the text of a subshape
Post by: Croc on February 12, 2020, 07:43:14 AM
You can try a construction similar to this.
EventDblClick=SETF(GetRef(Sheet.4!Scratch.B1),"OPENTEXTWIN()")
Let Doubleclick pass Opentextwin() function to the subshape.

Or you can use the backlink from the subshape inside the Dependson() function
[Group].EventDblClick=Now()
[SubShape].Scratch.A1=OPENTEXTWIN()+DEPENDSON([Group]!EventDblClick)
Title: Re: EventDblClick = OPENTEXTWIN() but then for the text of a subshape
Post by: Visisthebest on February 12, 2020, 11:06:30 AM
Thank you Croc will try these options for sure and let you know if I get them to work properly!
Title: Re: EventDblClick = OPENTEXTWIN() but then for the text of a subshape
Post by: Visisthebest on February 12, 2020, 12:12:05 PM
Croc this works really well!

EventDblClick=SETF(GetRef(Sheet.4!Scratch.B1),"OPENTEXTWIN()")

So writing to the Scratch section (I added it) is a trick to get in to text editing the subshape I assume?
Title: Re: EventDblClick = OPENTEXTWIN() but then for the text of a subshape
Post by: Croc on February 12, 2020, 12:42:24 PM
Yes. Visio performs the function at the time of recording. In this case, the function works in the context of the desired shape.
Title: Re: EventDblClick = OPENTEXTWIN() but then for the text of a subshape
Post by: Visisthebest on February 16, 2020, 06:02:08 PM
Thank you all for your input and help!