LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to make my first X control...

All I want to start is a string control that will automatically change the text background color when certain criteria in the string input are met.   (lets just say if the string includes "200 OK", the BG color will snap to green).

 

I know how to write the code I need, but where does the code go? 

 

Facade says "Drop the controls that make up the appearance of the XControl here."   So I've dropped a string, and can drag and drop the top level *.xctl on a front panel...

 

In the Facade's block diagram, am I evaluating the control that I just dropped or the "Data" string for the "200 OK"? 

 

Feels like a dumb question, but youtube isnt as helpful as usual-  Where do I read the string data inside the Facade block diagram?  I've tried both the Data shift register and the String control I created...

 

Thanks

 

 

 

 

0 Kudos
Message 1 of 5
(1,794 Views)

So the first thing I would do if you haven't is to set your string control to Update Value While Typing. That'll make it constantly re-evaluate the string value as you are typing into it, as opposed to waiting until after you click out of it. Add a Value Change event case for the string, and wire the string control directly to Data Out, and crucially, bundle in a True constant to the "Data Changed?" element of the Action cluster. If you do not do this, Data Out evaluates to Data In's last value. In the Data Change case, that is where you need to add the code to evaluate the string's value and possibly make a color change. 

 

This is where there are multiple avenues to arrive at what you want, but what I would suggest is add a color box constant to your Display State cluster, bundle in the appropriate color in the Data Change case after doing the evaluation, and if that color has changed, bundle a True constant to the State Changed? element of Action cluster. Then in your Display State Change case, that is where you can actually apply the current color to the control's background.

Redhawk
Test Engineer at Moog Inc.

Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.

Message 2 of 5
(1,778 Views)

I would think twice before starting to use Xcontrols, then think once more again.

 

Xcontrols seem neat but they have a lot of depth to them, but those depths are usually poorly documented and often buggy.  They're also weird in that they sometimes run during edit time, so you can have code running when you didn't think you would.  There's a good list of why they can be problematic here, inside the wiki article for an alternative method.

 

I would strongly recommend that you stay away from them and pursue an alternate architecture that allows for what you want to do.

 

Alternative 1:  The Q control toolkit

 

Alternative 2:  Use a Model-View-Controller architecture

Message 3 of 5
(1,757 Views)

Maybe consider Y Controls.

Version 3 of my Y Controls has been running smoothly for several months.

paul_cardinale_0-1665493180424.png

 

"If you weren't supposed to push it, it wouldn't be a button."
Message 4 of 5
(1,697 Views)

Thanks for all the suggestions!

 

I did manage to get my original idea working thanks to FireFist's input, but quickly realized that another (more complicated) instance of an Xcontrol I ran into some issues mentioned by Kyle... I was quickly stuck in deciding whether the added complexity was worth the additional "packaging"...  it's a tough call but thankfully I dont have to commit to anything now.

 

I didnt know about Q or Y controls and will have to dabble.  Also I had not seen that youtube about MVC (seems like a much more organized, yet similar way I've sort of adapted my QMH).

 

Thanks for the input folks! much appreciated!

0 Kudos
Message 5 of 5
(1,665 Views)