Jump to content

Dynamically Create Button Array w/Different Text?


lvb

Recommended Posts

I have hit a roadblock in GUI design for LabVIEW. I am attempting to create a "boolean button array" that has different text descriptions on each button. This can be easily done on the front panel using the boolean text of a button. However, my application requires the creation of dynamic button arrays. I will have a setup screen where the user can add and remove buttons (note the purpose of these buttons is to toggle a "DAQ" profile that displays different channels and scaling). I have attached a sample screenshot of the layout.

How can I dynamically add or simulate boolean text on a button?

If I create an array of buttons, the boolean text is the same.

If I create an array of clusters that contains a button and a text string, I cannot obtain events properly.

I have attached my starting VI and a picture of what I wish to add/remove items from during execution (dynamically). I am sure that some of the gurus on here have an elegent solution!

Thanks

Link to comment

QUOTE(brianafischer @ Jun 13 2007, 06:55 PM)

I have dealt with similar issues in the past. I couldn't find any examples, so I quickly put together a little VI to illustrate a couple ways of going about it. The first is the have a cluster of booleans that is as big as you ever want and dynamically change the visibility of the booleans. The second is to make that array of clusters you referred to. The key is to have a cluster of button and string and button. You need to have a transparent button over the top of the string to properly capture button presses. An alternate way of finding which array button was pressed (to what I did in the VI) is found http://forums.lavag.org/downloads-file11.html' target="_blank">here.

David

Link to comment

QUOTE(brianafischer @ Jun 13 2007, 08:55 PM)

I have hit a roadblock in GUI design for LabVIEW. I am attempting to create a "boolean button array" that has different text descriptions on each button. This can be easily done on the front panel using the boolean text of a button. However, my application requires the creation of dynamic button arrays. I will have a setup screen where the user can add and remove buttons (note the purpose of these buttons is to toggle a "DAQ" profile that displays different channels and scaling). I have attached a sample screenshot of the layout.

How can I dynamically add or simulate boolean text on a button?

If I create an array of buttons, the boolean text is the same.

If I create an array of clusters that contains a button and a text string, I cannot obtain events properly.

I have attached my starting VI and a picture of what I wish to add/remove items from during execution (dynamically). I am sure that some of the gurus on here have an elegent solution!

Thanks

David's ideas are probably the best way to go about tackling this idea. It's very reliable, and one of his solutions really points out the true nature of this problem. It's unlikely you really need an unlimited number of buttons. How many buttons can a user process visually? There's usually some max, even if it's 50 or more. So just statically have 50 buttons, and only show the number you need at that time.

Here's http://community.ni.com/examples/linked-object-list-in-labview-8-0-using-xcontrols/' target="_blank">another example you could look into if you have LV8.x, but I'd warn you that it's overkill and pushes the limits of what LV's built to do. But hey, that's half the fun...

Link to comment

Here is the example you gave which still uses an array of clusters. I have just changed the event case to use the y co-ordinates from the mouse up event to decide what button was pressed so that the button function and event return works better, you might want to change the event to mouse down though.

http://forums.lavag.org/index.php?act=attach&type=post&id=6090

Link to comment

QUOTE(dsaunders @ Jun 13 2007, 10:24 PM)

David, thank you for the idea. In my application I need to be able to use different preset keybords and get a boolean text of the pressed button. Array of clusters doesn't work for me because my keyboards are not "array" kind so I use a cluster of booleans. My goal was to handle all key presses in one event. Ok, it can be done if I assign each individual key's value changes to one event but this solution does not look elegant, I would like to to use <cluster><all elements><value change> event. After a slight modification I got this:

http://forums.lavag.org/index.php?act=attach&type=post&id=6105 http://forums.lavag.org/index.php?act=attach&type=post&id=6106

All keys have "switch until released" mechanical action to transmit "key down" when a button pressed and "key up" when it is released.

http://forums.lavag.org/index.php?act=attach&type=post&id=6107

Link to comment

QUOTE(yen @ Jun 16 2007, 02:37 PM)

yen, my variant is nothing else than a sort of your bottom event structure. But your variant with dynamic events is really awesome :thumbup:

By the way, which of these alternatives take more processor time etc? The one with dynamic events has less code repeated with each event for sure.

Link to comment

Yes, the point of the bottom one was just to show a simpler way of finding the changed element.

I don't know which would take less CPU work (I'm guessing the top one as well, but it is possible that the overhead involved with handling dynamically registered events would flip that around), but when you're talking about something like this, performance is practically a non-issue.

Link to comment

QUOTE(yen @ Jun 17 2007, 03:19 PM)

Yes, the point of the bottom one was just to show a simpler way of finding the changed element.

I don't know which would take less CPU work (I'm guessing the top one as well, but it is possible that the overhead involved with handling dynamically registered events would flip that around), but when you're talking about something like this, performance is practically a non-issue.

I understand that performance is not an issue here, this is a theoretical question. Anyway, dynamical events look more elegant. Thanks. :yes:

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.