LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

String control text position bug

Solved!
Go to solution

Hello again all you helpful forum posters!

 

I have a strange bug regarding a string control.  Some sort of property has been set which causes the text in it to display right-justified as normal until you press a key within the control.  Then the text jumps about 3 characters to the left.  Clicking on the right side of the new end of the text positions the cursor at the end of the text.  If I save the VI, the text jumps back to the right side.  Even stranger, if I just cover up the VI's front panel with another window, when I uncover it the text is on the right side again.

 

When I click in the text box with the mouse to position the cursor, the text does not move, but the cursor will only insert inbetween where the characters will go when they jump to the left, not where they currently are.  Highlighting exhibits the same behavior (see attached screenshot where I double-clicked in the control to highlight all text).

 

I copy/pasted this string control into a new VI with no logic, and it is behaving the same way.  Therefore I am assuming it is some sort of property I set at some point, but I can't figure out what so I can stop doing it in the future (which is also the reason why I am not just replacing my control with another string control and moving on - I don't want the new one to get corrupted in the same way).  I have attached the new VI for your reference.

 

The control is set to update the value as I type, and in my original VI (which I cannot post, unfortunately), I have two event cases that catch its value updates.  One looks for a value change of that control, checks whether it is over 12 characters and if so strips anything over 12 characters, and then runs it through the To Uppercase VI and assigns the resulting string back to the control.  The other looks for a value change it the control's parent cluster, and then takes the resulting control reference and passes it to a VI which saves the KeyFocus and TextSelection property values, sets KeyFocus false, changes the font to blue bold, and then sets the KeyFocus and TextSelection values to what they were (in that order).   I have to take KeyFocus off to bold it, I discovered.

 

Any suggestions as to what may be causing this would be appreciated.  Thank you!

 

-Joe

 

 

Download All
0 Kudos
Message 1 of 5
(3,073 Views)
Solution
Accepted by topic author jmorris

I'll wager that the text is right justified.  Select the text, go to the font pulldown menu, select Justify->Left and see what happens.

 

Edit:  Interesting.  Tried it out, changing justification to left and then back to right seemed to fix it.

Message Edited by Darin.K on 02-22-2010 01:01 PM
Message 2 of 5
(3,067 Views)

Well, changing the justification made the problem go away, so Kudos to you!  When I changed the justification to left, it worked.  When I changed it back to right (where I want it), it also worked, and stopped exhibiting the flawed behavior.

 

However, the fundamental question still remains for these reasons:

 

1) When I take a copy of the weird string VI that is still exhibiting the behavior, and I read the Justification property of the control, it also tells me it is already right.

 

2) I do not set the Justification property in my main VI anywhere.

 

3) The weird behavior seems to be a mix of right and center justification, based on whether I have covered up the front panel recently or not. 

 

4) The weird behavior is not even a reasonable mix of right and center justification - when the text jumps to the left, it does not stay centered when I add or remove characters.  It acts as though the right side of the control is 2 or 3 characters to the left of where it actually is.  So if I only have a couple characters, it is not actually centered.

 

All of which doesn't really matter, except like I said I'm concerned it will happen again, or other places where I adjusted the font through a control reference.  I'm happy that I can at least just always right justify whenever I change anything, but that seems like an awkward bandaid to cover up the real problem.

 

Any other ideas or suggestions?

 

-Joe

0 Kudos
Message 3 of 5
(3,045 Views)

I wouldn't worry all that much about doing it again since the fix is so easy.  In fact, other ways to fix this are:

 

1)  Resize by a very small amount

2)  Enable/disable Wrapping

3)  Changing the wrap at word breaks property

4)  Changing the font

 

My guess is that it was somehow corrupted, perhaps the VI was upconverted along the way, or just bad luck.  Let's hope this is the worst bug you encounter in LV.

Message 4 of 5
(3,026 Views)

My worry is that I will release an executable out into the field, and if the control gets corrupted there, my customers will not be able to easily fix it.  However, I haven't been able to reproduce the problem, and I don't really want to add left and then right justifying the control every time I change the font of it (since changing the font by itself did not fix the problem for me, unfortunately), both for code integrity reasons and because it would be visible to the user.

 

So I guess I'm going to try not to worry about it as you suggested.  It just makes me nervous!  Smiley Wink

 

And yes, of course I'm not complaining about the quality of LabVIEW in general; I've been extremely happy using it overall.  Smiley Happy

 

Thanks again!

 

-Joe

0 Kudos
Message 5 of 5
(2,997 Views)