Here’s the issue…
If StyledText and RTFData were Nil, an error should be raised.
To test the demo, enter some random text in the textarea, press add…enter another test “text” into the textarea and press add.
If you click entry 1 or 2 from the StyledText listbox…nothing happens…same with RTFData…but Text maintains the StyledText.Text!!! All three properties are set in the class computed StyledText property.
what is going on?!
FYI… on OSX… only clicking on TEXT re-fills the textarea… the other two do nothing
That’s the problem dave lol…all three listboxes should re-fill the textarea
Even worse, I use this same technique in my recently released SimDesignerCanvas. Odd part is…it works in the SDC control…but not this simple little demo!!!
Sorry… mis-read your orignal post… I thought you said it only did not work on ONE… so at least we have proven I can re-create the situation… and in debugger all the parts seem to be in the right place at the right time…
But it seems I ran across something like this a while ago… intriguing
StyledText is linked to the textarea. ie, when the text is cleared in the textarea, the styledtext object changes.
When you are setting the styledtext of the textfield, you are setting it to itself. (you’ve saved a reference to the object owned by the textarea rather than a copy)
The RTFValue is pulled from the StyledText object (owned by the textarea) rather than the rtfdata you saved.
The text is text and so it works.
I have two projects in front of me. Both use the same technique. One it works, one it doesn’t; Which is what led me to make this little demo, to see if there was “something else” in my code making it not work…and no, I’m not to blame :-p But why it works in one program and not the other is going to frustrate the heck out of me.
So when I save the RTFData as a string, shouldn’t the string still exist? Once it’s been converted from StyledText.RTFData (a string) to a string property…It should still exist yes? And StyledText is a Class of its own.
Dim x as new StyledText
x.RTFData = “the rtf data string”
then you could apply it to a textarea as,
TextArea.StyledText = x
so technically, the class exists outside of a TextArea, can only be applied to a textarea, and should exist whether it is attached to a textarea or not (as in the dynamic creation above)…and it still doesn’t explain why RTFData, which is a string, suddenly “no longer exists.”
THATS WHAT MY ISSUE HAD BEEN!!!
I had to clone the styled text into another instance First
SUB CLONE_STYLEDTEXT(master as StyledText,ByRef Clone as StyledText)
Dim i As Integer
Dim sr As StyleRun
For i=0 To master.StyleRunCount-1
dim st as styled text.
but yeah… RTF should have worked…
[quote=88325:@Matthew Combatti]So when I save the RTFData as a string, shouldn’t the string still exist? Once it’s been converted from StyledText.RTFData (a string) to a string property…It should still exist yes? And StyledText is a Class of its own.
Yes, but you are calling
Styles(me.ListIndex).StyledText.RTFData //the current rtf of the current state of the StyledText
Styles(me.ListIndex).RTFData //the RTF you pulled originally
Not the way this is set up
The styled texts items all refer to the same single instance attached to the TextAreas - they’d need to clone it
The RTF was grabbing the data back out of the StyledText.RTFData not the saved data
ok :-p thanks guys. I actually did that in my SDC but didn’t even think about creating another dynamic instance to hold the existing instance before destroying the original in my second project.