11-28-2008 04:44 AM
I'm calling the "Size to Text" method with an Invoke Node on a string control each time a keypress event is flagged.
Oddly, the string control never changes size. Have I misunderstood the purpose of "Size to Text" method?
Secondly, if I turn off "Update while typing" attribute, the keypress event is still registered by the event case, but the content of the string is consistently returned to the original string content - it becomes impossible to update!? Why does this behaviour occur?
Attached is my demo vi. If you run this, and try changing the content, you'll see the string control does not resize to the text.
Turn off the 'Update while typing' attribute, and it goes all crazy!
Any suggestions on how to get this to resize to the string content whilst the user types?
Solved! Go to Solution.
11-28-2008 04:52 AM - edited 11-28-2008 04:54 AM
Ok, I've answered the first part of the question by reading the help:

So I still need to find a way to resize the width of the control to the content text whilst the user types, and, less importantly, I still have no idea why the behaviour of the string control is to prevent content changes if Update While Typing is off. Can anyone help?
11-28-2008 05:15 AM
OK, with a lot more searching, I found a (password protected -grrrr) NI subvi called Get Text Rect
It (almost) returns the correct bounding rectangle for a font-formatted single line of text. With a slight correction, it works well for the large font that I'm using.
Solution attached.
Thanks to anyone who's spending time trying to solve this for me!