LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Question about custom buttons and references

I have a question about a custom button. I made a simple boolean with custom artwork for on and off. I have multiple copies of this button in my project. All I want to do is update the bitmaps, but doing so completely breaks the references throughout the code. I have to redo all of it and it is quite annoying. And another thing, when I update the type def the buttons do not automatically update despite being told to do so.

 

Is their a better way?

0 Kudos
Message 1 of 5
(647 Views)

Sounds like you want to make it into a Strict type definition.

 

Strict means that appearance plus data type changes are propagated, while a normal one only propagates type changes to existing instances.

 

Kyle97330_0-1691001418985.png

 

If that doesn't solve the issue, or only partly solves it, can you post with more details?  A copy of the type definition file, screenshots of what you change and how it breaks a reference, etc.

0 Kudos
Message 2 of 5
(636 Views)

Well, a strict typedef will not work because I want to be able to change the label text and font size.

As far as the reference goes, when I update the control by replacing it (one at a time) the control references used are automatically deleted as opposed to updated. I'll add a copy of the control in a moment.

 

I have a cluster of references I am using for the controls, and I load the reference into the cluster, then pass the cluster into my sub VI's for use as needed.

0 Kudos
Message 3 of 5
(620 Views)

I've done this a few times.  Let's say you want the Button to have 3 "options", i.e. say "Do One Thing", "Do Another Thing", and "Do Something Else".

  1. Make a Rectangular button.  Name it (and label it) "Do One Thing".  You can "decorate" it, as well, if you want.
  2. Make two copies, named "Do Another Thing" and "Do Something Else".  Make sure all three are exactly the same size (Right-click the Control and look at "Appearance" Property).
  3. Stack them one on top of the other.  It doesn't matter in which order.  For ease of use, once they are stacked, select them all (drag a selection box around them), go to the "Reorder" button (to the right on the Menu bar) and choose Group.  This "binds" the three Controls together.

Now comes the Magic.  Let's say you put "Do One Thing" on top and "Do Something Else" on the bottom.  Go to the Block Diagram.  Right-click "Do Another Thing" and choose "Hide Control".  Do the same with "Do Something Else".  Now look at the "Triple Control" -- it says "Do One Thing", and if you click it, it will change from Default (False) to True.  The other Controls remain the same (you never pushed them, they were invisible).

 

When (and to what) do you want the "Do One Thing" button to change to, say, "Do Something Else"?  All you need to do is change the Visibility of "Do One Thing" to False (making it "invisible" and "unpushable") and change "Do Something Else" Visibilty to True.  

 

Note that the Square Booleans have Mechanical Actions "Latch when Released", and the Control is usually placed inside an Event Case which automatically resets the Control to False.  What you would do is in this Event Case, change the Visibility property to False and the Visibility of "Something Else" to True.  You would then call (via a Queue for a QMH or a Messenger Channel for a CMH) the next "State" or "Action" in the Message Handling Loop.  And (as the British say), "Bob's your Uncle".

 

[I first "invented" this technique more than a decade ago on my first major LabVIEW project (though I'm sure others thought of this before I did).  I had a Front Panel with a big green "Start" button and a bunch of Controls I had to set, including opening up an Excel Workbook showing the parameters for the testing routines my colleagues would be running on subjects (a "Where's the Sound Coming From?" study).  Once they pushed "Start", it "magically" changed to an equally big red "Quit" button.  I'll admit that, thus far, I've never used more than a 2-button "stack".]

 

Bob Schor

 

 

0 Kudos
Message 4 of 5
(554 Views)

I've thought about creating a custom pop-up menu item that applies, in the manner that I want, the changes of typedefs to controls.

But I never got past the thinking-about-it stage.

Maybe you should think about it too.

0 Kudos
Message 5 of 5
(528 Views)