Data Shape and Text input field mutually exclusive

Started by Machine, April 03, 2020, 10:04:23 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Machine

I am trying, without success, to create shape where its text content can be changed via Shape Data and also just by typing value to text field.
Unfortunately while changing value in Shape Data content of Text Field (Value) is being overwritten - more precisely, being removed.
Similarly typing directly to Shape does not update Prop.Value in Shape Data.

I am in dire need to allow writing content to Shape both ways.


vojo

I am not sure I understand.   You want 2 ways to update a single piece of text presentation in a shape?
If its the same piece of text, isn't which ever method you use will over write it?

Anyway,
if you want this to be a "collision of input"  then in the shapesheet, 2 functions might help you.   SETF and DEPENDSOB
SETF will allow you to push something into a cell.   DEPENDSON will trigger evaluation of a cell based on changes
With these, you could do some sort of "inbound text from 2 methods"

Normally, taking inputs from different input modes is done as follows via shape sheet.
Lets assume you have a square where you want to change its dimensions.  Obviously could widen or heighten the square,
but lets say you want to have both an option for real precision or an option to use handles.
(square is trivial but illustrative.., for a simple square you would never do this)

First you need an way to select which input mode...add actions to square
actions.mode = setf(getref(actions.mode.checked),if(actions.moded.checked, 0,1))
Actions.mode.label = "input mode is shape data"
This will create a item for selection in the drop down   (right click the shape....at the top you will see it)

Next you need some shape data
props.width
props.height

Next some controls  (these allow you to graphically adjust the shape size...wont go into all these details...suffice to say
you get them working)
controls.w  and controls.w.y

next some user cells
user.w = if(actions.mode.checked, props.width, controls.w)
user.h = if(actions.mode.checked, props.height, controls.w.y)

Now in the geometry section, use these user.w and user.h to define the dimensions.

ok...some advice.  First, start small...make sure actions work....check field turns on and off..then shape props...then etc.
Second, use some other user cells or props cells to show values at various points (ala debug).

see attached



Machine

#2
Unfortunately, it is not what I had in mind.

Made quickly an example - can be found in attachment.

By my understanding if I want to control value of one cell via 2 different inputs, I should use SETATREF() and SETATREFEXPR()
I have found about those 2 functions right now.

Hopefully file will clarify a bit, what problem I have.


edit:
Quote from: vojo on April 03, 2020, 12:40:31 PM
If its the same piece of text, isn't which ever method you use will over write it?

The final piece of text has to be overwritten, no matter is it comes via direct input to shape, or via Shape Data.
But!
Once new value is entered into the Shape I want Cell in Shape Data to update accordingly,
and if user enter data to Shape Data's cell - TheText has to be updated as well.

wapperdude

Not aware of a technique to do what you want without code.  The problem is there's no text cell.  You thinking about using setatref is good, except it needs a target cell.  The Insert field creates the Field section and does create a target cell...which is a usable candidate.  However, direct adding text to shape (including from GUI, I think) clobbered this.  Subsequent data entries then fail.  There is no shapesheet field section to add manually.  It is created by the Field insert process.

Bottom line:  one or the other, not both.  To prevent "direct" entry, you will need to "protect" text editing.

Visio 2019 Pro

Machine

I was afraid that this might be the case.
Was trying to use something like:
=SETF(GetRef(TheText),Prop.Value)
but couldn't make it work.

Have 2 other ideas that might potentially work, but it will take some time to test them out.

Thanks for help!
If I'll find solution, I'm going to post it here later!

Machine

OK. So finally I was able to find a way to bind to inputs to "one" Shape.
Although it is not one, but two - and I used some trickery to make it happen.

Main Shape (the one which takes input) is set with HideText = True
Child shape takes the responsibility of showing value of input.

The only big issue I cannot resolve, is wired behavior of TheText cell.
Incredibly annoying!
It seems whenever shape is updated (and the update relate in any way to text) SHAPETEXT(TheText) is being triggered, that cause of passing its value to another cell:

=SETF(GetRef(Prop.Value),""""&SHAPETEXT(TheText)&"""")


Basically all I need to do is to move the shape to revert last input;
if last input was given via typing in into Data Shape, then moving the shape cause reupdate with value from TheText
(its easier to understand playing with example)
----------
Now, question is: how I can prevent triggering the event (TheText)?
Or maybe there's another way... ?










vojo

you can use a user cell to hold previous input based on changes in shapetext

or even 2 user cells to create a pipeline using different triggers....pick the one you want

Probably need to play around with it. But in general use the shapetext event to save in 1 user cell.
use a different trigger to copy user.cell 1 to user.cell 2 

Machine

I was trying quite a lot of different ideas, none of them worked.
Currently I am working with a concept of controlling the direction of copying data between Prop.Value and TheText, using one boolean.
In terms of using extra cell to store data - this is exactly what I did - doesn't work because of the fact I don't have control over TheText and its continuous evaluation, and saving the data to another cell.

Croc

I would like to add another option.
This is a rather cumbersome decision, but maybe it will lead to other useful thoughts.
This works in a shape-group. The group is used to enter data, and the internal shape is used to display data.

Croc

Main formulas are:

Group (Sheet.22):
User.text - must be added
Prop.Text.Value=SETATREF(User.text,SETATREFEVAL(SETATREFEXPR("rrrrr")))
TheText (Events)=SETF(GetRef(User.text),"SHAPETEXT(TheText,0)")
DisplayMode=0

Internal shape (Sheet.21):
TextField.Value=Sheet.22!User.text
LockTextEdit=1

Machine

#10
Thanks for the input!
It is very similar solution to mine, better and cleaner execution than mine, but with exactly the same problem as in my file/example, ie:
when data is being entered to "text" cell in Data Shape, and the whole shape is being moved - it reverts entered value to the last one entered directly to shape.
It is quite unfortunate how events are working, and something is telling me no one can deal with this particular problem, in the current state - the way internal parts of Visio works.
----
bottom line:
I am trying to create a workflow/standard, so as many different coworkers as possible (with different approaches and knowledge) can use tools I am creating.
That's why 2 way input would be a great addition to my current project.
And it's a nice exercise too ;)

wapperdude

See attached.  Takes two shapes...a group shape with one member shape.
Group shape accepts either direct entry or a Shape Data entry.
Group shape does not display text, the member shape does.

Member shape does not allow text editing.  If "polls" the group to see if directly entered text is present by using the "Len" function.  If present, this is displayed via Field Insert.  If not, then, shape data is displayed.  This prevents the Field Value from being clobbered and disappearing.  There is a conditional statement that sets the priority of which text is used first.

Also included a bonus piece of text... just show example of possible optional formatting.

NOTE:  did not explore what happens if both direct and data entries are empty.  Suspect the Field Insert disappears.  May have to add a temporary placeholder to keep it present.
Visio 2019 Pro

wapperdude

Up dated to include the "placeholder" text.  It disappears if direct or data text is entered.  Come back when both have no entries.

Added dbl click to the grp shape to bring up data entry.  Changed grp behavior to allow only grp selection.
Visio 2019 Pro

Machine

Finally done, after over-complicating things, I have found a solution.

Shape takes input from two sources: TheText and Prop.
Updates output and Prop accordingly, and holds the value of last input
(which was a problem before).

The only downside: it requires to use 3 User Defined Cells

user.1=SETF(GetRef(Prop.Value),User.3)
user.2=SETF(GetRef(Sheet.2!Fields.Value),Prop.Value)&IF(STRSAME(User.3,SHAPETEXT(TheText)),"",SETF(GetRef(User.3),CHAR(34)&SHAPETEXT(TheText)&CHAR(34)))
user.3=(value of previous input from TheText)

scott

This is really interesting, @Machine. It even works if you set the shape's double-click behavior to edit the shape's text.

In the past I've written a couple of lines of VB code to accomplish the same thing but now I need to revisit those solutions to see whether this technique will do the job. Thanks.