Visio Guy

Visio Discussions => ShapeSheet & Smart Shapes => Topic started by: Hellboy on May 04, 2018, 12:54:25 PM

Title: Custom List is destoyed after placement from stencil [SOLVED]
Post by: Hellboy on May 04, 2018, 12:54:25 PM
Hi,
I`ve created a list on a worksheet and put it on a stencil. After this, I dragged it from a stencil to a worksheet and it became a simple group.
What`s wrong? Should I create it in a stencil?
Title: Re: Custom List is destoyed after placement from stencil
Post by: Yacine on May 04, 2018, 03:18:38 PM
The master in the stencil must always be one object (either single shape or a group of shapes).
If you really need individual shapes, you can ungroup the shape (automatically or manually) on drop.
Title: Re: Custom List is destoyed after placement from stencil
Post by: Hellboy on May 04, 2018, 03:54:14 PM
Quote from: Yacine on May 04, 2018, 03:18:38 PM
The master in the stencil must always be one object (either single shape or a group of shapes).
If you really need individual shapes, you can ungroup the shape (automatically or manually) on drop.
Yes, I created a group first and made a list after (I looked at some standard list as an example).
Title: Re: Custom List is destoyed after placement from stencil
Post by: Yacine on May 04, 2018, 04:52:08 PM
Can you upload your shape?
Title: Re: Custom List is destoyed after placement from stencil
Post by: Hellboy on May 04, 2018, 05:02:01 PM
Quote from: Yacine on May 04, 2018, 04:52:08 PM
Can you upload your shape?
Yes, done
Title: Re: Custom List is destoyed after placement from stencil
Post by: Yacine on May 05, 2018, 08:22:05 AM
As suspected: the list is not a single object.
1. Write a macro as described here: http://visguy.com/vgforum/index.php?topic=26.0
1. Group the list
2. Add the according CALLTHIS function in the ONDROP event cell
3. now you can drop the grouped list in your stencil, it will ungroup when you drag it back into your drawing.

Cheers,Y.
Title: Re: Custom List is destoyed after placement from stencil
Post by: Nikolay on May 05, 2018, 10:43:15 AM
+1.. Master can be a single shape only (i.e. either a shape, o a grouped shape). You cannot have list as a master shape directly.
Title: Re: Custom List is destoyed after placement from stencil
Post by: Hellboy on May 06, 2018, 11:32:22 AM
Ok, I've deleted all list items, put an empty list on a stencil and returned it back to a worksheet, everything is ok, it is a list, not a simple group.
I can drag my ListItem shape to it and populate my list. But I want to use EventDrop functionality...
So, I try to use:
User.msvSDListItemMaster = USE("ListItem")
Events.EventDrop = IF(LISTMEMBERCOUNT()=0,DOCMD(2270),0)
to trigger insertion of my "ListItem" into the list.
But it is doesn`t work. My list item is on a stencil and has name "ListItem". What`s the problem?
Title: Re: Custom List is destoyed after placement from stencil
Post by: Nikolay on May 06, 2018, 11:45:15 AM
That approach should work. You are following this article, right?
https://blogs.msdn.microsoft.com/visio/2010/01/12/custom-containers-lists-and-callouts-in-visio-2010/

Here is a simple example (attached)
Title: Re: Custom List is destoyed after placement from stencil
Post by: Hellboy on May 06, 2018, 12:41:10 PM
Thank you, Nikolay for your simplest example. I compared your list and mine and found out that the problem was in the following:
Name of my ItemList was horItemList and even after renaming, it has an old name.
Then I deleted it from a stencil and inserted it in a stencil one more time. After this everything is OK.
I think it is a bug.
Many thanks to Nikolay and Yacine for help and Microsoft for a bug :)
Title: Re: Custom List is destoyed after placement from stencil [SOLVED]
Post by: Hellboy on May 06, 2018, 12:55:32 PM
RESUME
1. Delete all list items before list placement to the stencil (leave header shape if it is not an item of a list).
2 (optional). Add two rows to a list`s ShapeSheet to automate the population of the new list after placement on a worksheet:
User.msvSDListItemMaster = USE("ListItem")
Events.EventDrop = IF(LISTMEMBERCOUNT()=0,DOCMD(2270),0)
Title: Re: Custom List is destoyed after placement from stencil [SOLVED]
Post by: vojo on May 06, 2018, 09:42:57 PM
to your amusement, 2003 didn't have this problem (did this lots of times)
I guess I can add it to the "101 things 2003 did better than 2013"  ;-0  ;-)
Title: Re: Custom List is destoyed after placement from stencil [SOLVED]
Post by: Nikolay on May 06, 2018, 09:47:07 PM
Hmm.. But Visio 2003 does not have lists?
From the other side, since it does not have lists, it does not have any problems with them :)
Title: Re: Custom List is destoyed after placement from stencil [SOLVED]
Post by: vojo on May 07, 2018, 03:33:11 AM
you can make them with props fields and actions.
So technically, yes not identical 2003 but 2003 you can even make lists that spawn other lists...and all can be stored in stencil