Visio Guy

Visio Discussions => General Visio => Topic started by: Lars-Erik on May 21, 2008, 11:16:35 AM

Title: Locked (Read-only) Custom Properties / Shape Data Fields
Post by: Lars-Erik on May 21, 2008, 11:16:35 AM
Ok here goes, I want users to insert data for each shape.
There are however some data fields I do want to show, but not allow users to change.
The reason for this is that I'm linking Visio with a PDM tool, the tool reads the drawing and then assigns a number, description and class to each shape according to its data in Visio (that the user does enter).
So the shape data holding the tool's data need to show up in Visio but cant be edited, one way to do this is using Guard("Assigned number"). Users can still edit the fields, but it wont be changed as its guarded. What I'd like to know is this: Is there a nicer way of doing this, perhaps grey out the field?

- Lars
Title: Re: Locked (Read-only) Custom Properties / Shape Data Fields
Post by: Visio Guy on May 21, 2008, 01:40:00 PM
Very often requested feature (in fact, how about putting this in the Visio 14 Feature Requests (http://visguy.com/vgforum/index.php?board=9.0)?

Crappy work-arounds I have done in the past:

Title: Re: Locked (Read-only) Custom Properties / Shape Data Fields
Post by: Lars-Erik on May 21, 2008, 02:03:09 PM
Mmmm, ok. Suppose the best option is to work with Guard (as i want to keep the properties out of the drawing and only show up in the property listings.)

Guess best case scenario, make a checkbox (a boolean in the shapesheet) that makes it "disabled"
Ill post it in requested features. Thx for the response Chris.

- Lars
Title: Re: Locked (Read-only) Custom Properties / Shape Data Fields
Post by: vojo on May 26, 2008, 03:34:12 PM
custom property that is a fixed list where the format has the actual data.   You can show, but user cant change
you may want 1 custom property to allow user to set the value....another to display elsewhere where its format and data come from the first custom property
Title: Re: Locked (Read-only) Custom Properties / Shape Data Fields
Post by: Lars-Erik on May 26, 2008, 03:42:50 PM
Mmm, that and using Guard() are probably the two best workarounds. But still... there workarounds. Ive posted this as a requested feature.
Title: Re: Locked (Read-only) Custom Properties / Shape Data Fields
Post by: Visio Guy on May 26, 2008, 08:47:55 PM
Thanks vojo,

I knew there was another technique that I was forgetting!

So for newcomers to this thread, here's another way to create a read-only Shape Data (Custom Property) field: make it a fixed list with one item!

For example, "Prop.Info" would be set up like this:

Prop.Info.Label = "Info (Read Only)"
Prop.Info.Type = 1
Prop.Info.Format = "The Only Value"
Prop.Info.Value = "The Only Value"

Note: Normally, the Format cell holds a list, such as "Item 1;Item 2;Item3", but by putting only one item in the list, the user can't change it, just read it.

Also, I put a "(Read Only)" reminder in the .Label cell. Not a requirement, but perhaps a UI enhancement to help your users.



Title: Re: Locked (Read-only) Custom Properties / Shape Data Fields
Post by: perry59 on January 08, 2021, 09:07:12 PM
Sorry for reviving such an old post but I have a need.
I too wish to guard shape data, but I see NO cell in the protection area of the shapesheet for custom properties.
I see a cell for disallowing adding custom props, but no cell for disallowing editing of custom props
How do you do this?
thanks
Title: Re: Locked (Read-only) Custom Properties / Shape Data Fields
Post by: vojo on January 08, 2021, 11:03:13 PM
if you really want to lock a prop field, then 2 options

Option 1:  If never changed then  prop.mycoolfield.value = guard(<value>)

Option 2:  If you want some change values but lock when done then more complicated.
               need to can use the setatref functions (not trivial at all)  or
               prop.mycoolfieldpubic = guard(prop.mycoolfieldprivate)
               prop.mycoolfieldprivate = <value>     
               logic around prop.mycoofieldprivate.hidden to control when visible and when hidden.  if hidden, user cant change

for option 2, you should experiment on a dummy shape  before you implement in your shape.
get the logic right and test all the use cases
Title: Re: Locked (Read-only) Custom Properties / Shape Data Fields
Post by: perry59 on January 09, 2021, 04:44:38 PM
had a brain lapse there, remembered how to do that :o

Thanks!
Title: Re: Locked (Read-only) Custom Properties / Shape Data Fields
Post by: Visisthebest on January 10, 2021, 10:14:29 AM
Visio Guy thank you very much for this great tip!

Quote from: Visio Guy on May 26, 2008, 08:47:55 PM
Thanks vojo,

I knew there was another technique that I was forgetting!

So for newcomers to this thread, here's another way to create a read-only Shape Data (Custom Property) field: make it a fixed list with one item!

For example, "Prop.Info" would be set up like this:

Prop.Info.Label = "Info (Read Only)"
Prop.Info.Type = 1
Prop.Info.Format = "The Only Value"
Prop.Info.Value = "The Only Value"

Note: Normally, the Format cell holds a list, such as "Item 1;Item 2;Item3", but by putting only one item in the list, the user can't change it, just read it.

Also, I put a "(Read Only)" reminder in the .Label cell. Not a requirement, but perhaps a UI enhancement to help your users.
Title: Re: Locked (Read-only) Custom Properties / Shape Data Fields
Post by: Phojes on August 05, 2021, 05:48:47 AM
Hey guys, here comes another late reply / addition:
Is there any way to protect the "name" cell for custom properties from changes? So it is only editable in the shapesheet and not via "define shape-data"?
For all the other cells I'm fine with usind the guard()-function but that doesn't work there, of course.
Title: Re: Locked (Read-only) Custom Properties / Shape Data Fields
Post by: Surrogate on August 05, 2021, 06:17:58 AM
Quote from: Phojes on August 05, 2021, 05:48:47 AM
Is there any way to protect the "name" cell for custom properties from changes?
There is not "name" of cell, it is "label" !
(https://i.ibb.co/Jc6RVsP/Lock-Label-Name.png)
You can create user-defined cell with formula like this
QuoteIF(STRSAME(Prop.Row_1.Label,"OLOLO"),SETF(GetRef(Prop.Row_1.Label),"""ololo"""),SETF(GetRef(Prop.Row_1.Label),"""ololo"""))
Title: Re: Locked (Read-only) Custom Properties / Shape Data Fields
Post by: Surrogate on August 05, 2021, 07:22:24 AM
Quote from: Surrogate on August 05, 2021, 06:17:58 AMIs there any way to protect the "name" cell for custom properties from changes?
If the user does not enable developer mode, he only sees the label in the "Define shape data" window.
But when developer mode is enabled, you will see the names of the rows that you can't prohibit to change the row name.  :(
(https://i.ibb.co/fYMmbxf/Define-Shape-Data-DM.png)
Title: Re: Locked (Read-only) Custom Properties / Shape Data Fields
Post by: Visisthebest on August 05, 2021, 04:26:27 PM
Is it possible in VBA to check if Developer Mode is enabled, and to enable/disable it with VBA?
Title: Re: Locked (Read-only) Custom Properties / Shape Data Fields
Post by: Surrogate on August 05, 2021, 05:08:46 PM
Quote from: Visisthebest on August 05, 2021, 04:26:27 PM
Is it possible in VBA to check if Developer Mode is enabled, and to enable/disable it with VBA?
you can check it
Application.Settings.DeveloperMode and turn out
If Application.Settings.DeveloperMode Then Application.Settings.DeveloperMode = Not Application.Settings.DeveloperMode
Title: Re: Locked (Read-only) Custom Properties / Shape Data Fields
Post by: Visisthebest on August 05, 2021, 08:28:18 PM
That is super thank you Surrogate, there are often situations where I want to warn the users not to use Developer mode and go tampering with the internal setup of shapes, as this will break the respective diagrams!
Title: Re: Locked (Read-only) Custom Properties / Shape Data Fields
Post by: Phojes on August 10, 2021, 07:02:04 AM
Okay, thank you Surrogate! That is something I can work with!