LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
GregFreeman

Greyed out default string in string controls

Status: New

I would like if there were a default value for string controls that would be greyed out, but the string value would still be a blank string. This could be useful in showing example text for text that should be entered in a specific format. I have shown an example of the (visual) functionality and the code that goes along with it. This code could be greatly reduced if there was a key focus event added, but even in this case, the string control value itself is still not an empty string. I could also see this being beneificial in listboxes, multicolumn listboxes, tables etc.

 

7 Comments
dthor
Active Participant

I like it! Could (should?) the same be done for numerics and other Controls?

 

However, I think that this should not be linked to the default value. I'm trying to think of a way that this could work, but I keep running into issues such as: Which value to you display: the grey "pre-edit" value or the default value? I want them unlinked so that you could have this grey text be there until the user enters something. If the user doesn't change the control, is uses the default value. Perhaps a property called "pre-edit value" or something like that. Something that we can program in or edit with the control's properties box.

fabric
Active Participant
I would avoid any association with the default value. The "help text" or whatever we call it should be an additional property (or could even reflect the existing "tip" property)... Then we just need a property for "show help text/tip when empty" or something like that.
JeffreyH
Member

Kudo if it is implemented using fabric's proposition.

tst
Knight of NI Knight of NI
Knight of NI
I'm not sure what I think about the idea, but there's an XControl which does this here - https://decibel.ni.com/content/docs/DOC-18396

___________________
Try to take over the world!
GregFreeman
Trusted Enthusiast

Dthor, I don't think it should be used with a numeric control because an empty string is valid, an empty numeric is not. I also agree with fabric that it should not be associated with the default value, but instead should be its own property. I do, however, think it should be unrelated to the tip strip, just for the sake of having more flexibility. Finally, tst, I have not tried the code at the link you provided, but the problem I have with my code is that if the user clicks in the string control, then clicks off without typing anything it changes the font to black. Also, it seems you always have to be checking if the value in the string is equal to your "greyed out string" to determine if you should use the string in the control or ignore it. This could potentially cause problems if the user wants to enter a string that's the same as the example string. But, like I said, I didn't look at the code yet so please let me know if I'm wrong about this. For instance maybe they played some tricks with text in a picture control on top of the string or something. Either way, I feel these are all too confusing!

Silver_Shaper
Active Participant

Kudo for tst.

 

---
Silver_Shaper | CLD
altenbach
Knight of NI

See also my (first) comment in this idea discussion.