Accessing button properties in an array of clusters ...
I have a situation whose solution is eluding me.
I built an array of clusters (15 of clusters in the array). Each cluster is a boolean LED control and a path control.
The array is wired to various VIs. One of these VIs is supposed to
select a path from the array and then change the color of the LED that
is clustered with that path. The path part works because I am reading
the value of that array element. The problem is that I don't know how
to get to the associated LED properties.
I have used several approaches, but in all cases: when I change the color of the target LED, all 15 LEDs change color.
Inside of a while loop with indexing enabled, I have unbundled the
current cluster and then tried to apply a property node to the LED
element but all LEDs change color.
So the question is - How do I access the individual LED properties in an array of clusters?
In an array only the values can be different for different elements. The properties are the same for all elements.
You can work around this by using a color box, which has the color as the value.
Here is an example of a color box customized to look like a LED with an explanation of how it was created.
Try to take over the world!
Similar Messages
-
Accessing button properties in datagrid row?
Hi
I ve a datagrid which has a button in each row called "Select". When the user clicks the button it calls a function which saves the row details in an array. I also want to change the label and icon of the button but don't know how to access it?
I ve tried giving each button a unique ID but I "is not a valid identifier" so I m really not sure how to access each button from my main script, anyone help?
Cheers in advance
ShaunHi
Thanks for replying, I m still unsure of how to access the properties of a button in a row? I currently have the code below and am struggling to access the properties of the 'Add' button so I can change the label and icon?
Cheers
Shaun
<mx:columns>
<mx:DataGridColumn headerText="Group" dataField="groupName" width="130" editable="false" sortable="false" />
<mx:DataGridColumn headerText="Article Number" dataField="articleNumber" width="200" editable="false" sortable="false" />
<mx:DataGridColumn headerText="Article Name" dataField="slideTitle" width="230" editable="false" sortable="false" />
<mx:DataGridColumn headerText="Colourway" dataField="colourway" width="218" editable="false" sortable="false" />
<mx:DataGridColumn editable="false" paddingLeft="5" sortable="false">
<mx:itemRenderer>
<mx:Component>
<mx:VBox>
<mx:Button label="Add" icon="@Embed(source='assets/icons/add.png')">
<mx:click>
<![CDATA[
outerDocument.addItemToCart(data);
]]>
</mx:click>
</mx:Button>
</mx:VBox>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn> -
Hey everyone,
I'm new to Labview and am trying to create an array of clusters. I have a 16-channel TTL I/O interface and I want to access each channel of the I/O. Each channel has an input/output boolean button and an output high/low (0 or 5 V) boolean button. I want to be able to read what my output selection is set to with an enum indicator. What's the best way to be able to access, say, channel 7's input/output selection? Or how would I read channel 12's output setting? Thanks a bunch!Hello!
Sounds good -- let us know if we can help out in any way!
Message Edited by Travis M. on 11-01-2005 11:19 AM
Travis M
LabVIEW R&D
National Instruments -
Change properties of a cluster element withing an array of clusters
Hello all,
I have an array of cluster that is shaped as a line with different display elements.
A list or a tree wouldn't have made it, so I had to use a cluster and make a table.
The problem is that I want to change not only the text but also the text color.
Individually.
I found this :
http://www.ni.com/example/30904/en/
But it change the property in all the clusters in the array, not just the one I need.
Some people have the same problem :
http://forums.ni.com/t5/LabVIEW/Reference-to-Array-of-Clusters-with-an-array-element/td-p/1006427
http://forums.ni.com/t5/LabVIEW/Different-set-of-values-for-two-rings-in-an-array-of-clusters/m-p/10...
http://forums.ni.com/t5/LabVIEW/array-of-clusters-get-references-to-all-the-clusters/td-p/1079456
http://forums.ni.com/t5/LabVIEW/How-can-I-reference-the-properties-of-a-control-in-a-cluster-in/m-p/...
http://forums.ni.com/t5/LabVIEW/Writing-only-to-certain-cluster-elements-in-an-array-by/m-p/2200728
http://forums.ni.com/t5/LabVIEW/Update-Properties-Of-One-Control-In-An-Array/m-p/3015501
http://forums.ni.com/t5/LabVIEW/Array-of-clusters-and-in-the-cluster-is-a-bar-meter-how-can-I/m-p/15...
http://forums.ni.com/t5/LabVIEW/Property-node-of-a-control-inside-of-cluster-inside-an-array/m-p/946...
Obviously, while in a list/table or tree you can change the property of an individual
cell (font, color) you cannot do it within an array of cluster, by some sort of magic,
the property of a cluster element (font, color) are all linked together, hence rendering
the use of an array worthless.
A possible hack is proprosed by using control masking, setting one visible and the
other invisble, swapping their position, whatever. It's a hack you have to perform,
hence add another code to maintain.
Is that still the case or is there now a more official way to handle individual cluster
properties, not just its data ? After all that's a common real-life example that should
be handled by Labview. In my opinion.
David Koch
Solved!
Go to Solution.altenbach wrote:
One of the elements could be a 2D picture indicator of about the same size. You can write text in any color using picture functions.
Here's what I had in mind. Seems to work just fine (I would fine-tune the font, picture border, etc. but this should get you started).
LabVIEW Champion . Do more with less code and in less time .
Attachments:
ColorText.png 13 KB
ColorText.vi 9 KB -
Change properties of controls in an array of clusters
Hello,
my latest problem:
i display larga amount of data using arrays of clusters.
the user has to be able to inserst clusters in between, therefore the array solution seems perfect.
However, for each cluster, once a sub-control is defined, i would like some other sub-controls to either become invisible, visible, change ring values...etc.
i could not find any way to do it whatsoever. anybody has an idea?
... And here's where I keep assorted lengths of wires...Hey good work!
I sounds like you are on the right track, so here are a couple more things to throw into the mix. First, remember that given a reference to a "top-level" cluster you can extract references to all the controls inside it on the fly. For example, you take a cluster reference, it has a property called "Controls" this is an array of of references to all the controls inside that cluster. If each of those references is itself a cluster, you can in turn get references to all the controls inside them. Hence you don't really need references to each individual control on the front panel. In fact, all you have to do is figure out how to update one of the inner clusters and then put that code inside a loop so it executes once for each reference in the top-level cluster's Controls property array.
Second, think about how you can generalize the operation such that the you can turn them into subVIs that you can use no matter what the structure of the clusters might be... The information is all there in the control properties.
Finaly, yes I can post an example. I'll put one together this evening and try to get it up online.
Mike...
Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion
"... after all, He's not a tame lion..."
Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps -
Drag And Drop Element Of Array Of Clusters
I have a project that includes an array of "tests", each of which is a cluster containing an array of "part numbers", a regular expression matching string and an array of "test tasks" (each of which, is in turn, a cluster of elements).
That is:
Tests (array of):
Cluster:
Part Numbers (array of strings)
Regex (string)
Tasks (array of):
Cluster:
Task type
Base Channel,
Measurement Channel
Other Channels
I'd like to be able to drag and drop to re-order the task array within an individual test. (It's a nice-to-have rather than an urgent request - more for my own learning than anything). For now, I've implemented "Move Up" and "Move Down" buttons.
The examples are fine for a single cluster that includes an array, or for an array of objects. As soon as we have an array of clusters, it's hard to access the individual elements within a specific cluster.
Has anybody successfully implemented drag and drop within such a setup?
Curiously,
Geoff
Geoff Field, BE, CLAD, MIEAust
Professional geek, amateur stage-levelling gauge
Solved!
Go to Solution.Hello GeoffF,
This is definitely doable, and you can even use the standard start drag and drop methods/events, the tricky part is determining the array elements that are being selected on mouse up/mouse down and handling the swap manually. Luckily, there are a couple decent examples of how to do this out there already, I'd suggest you take a look at this one:
Community Example: Determine Clicked Array Element Index in LabVIEW
https://decibel.ni.com/content/docs/DOC-22434
That should give you the selected array indices, and then all you have to do is switch the elements around around in the drop event. I've attached a very basic demonstrative example that uses that code I just linked (you'll need to download that as well) and the events mentioned to swap two array elements. The attached code is just thrown together, you'll want to design something more robust and scalable for any sort of real use.
Regards,
Tom L.
Attachments:
array drag.vi 21 KB -
Using Event Structures with Array of Clusters
Using LabVIEW 8.5
Hi all,
I'm trying to convert an existing application to one that can be used
through a touch screen. I updated the UI and added an event structure
to listen for mouse ups on controls that require a HMI keyboard or
numpad to show up. Although I've been programming for a while, I'm new
to LabVIEW and am struggling with a problem:
Is there any way to have an event case listen to an event within
arrays? I've seen a few examples on the forums, but they all start with
breaking up the arrays into individual variables. Using the variables,
they build arrays. This seems pretty tedious, and I'm pretty sure I
can't apply it to one of my arrays. Essentially, I just want to know
which cluster in which array the user has clicked on, so I can open the
HMI keyboard or numpad and send the text to that cluster. In my watered down app (Array of Clusters.vi), I've put 3 arrays of clusters and a few stand-alone controls to give you guys an idea of what I'm taking about.
BTW, I'm using the HMI Keyboard and Numpad built by the Beta Community (http://decibel.ni.com/content/docs/DOC-1062) and modified it to add a "Clear" button to the keyboard and numpad. Please let me know if I implemented this in the best way.
Thanks for the help,
Kunal
Message Edited by bhatiak on 08-04-2008 03:55 PM
Attachments:
Array of Clusters4.llb 274 KBMy old tic tac toe example shows how to determine which square of a 2D array has been clicked.
http://forums.ni.com/ni/board/message?board.id=170&view=by_date_ascending&message.id=247044#M247044
You probably can adapt some of it for the arrays on the right. If the array can be scrolled, you also need to account for the "indexvals" offset.
The Layers controls is easiest, because you only show one element. Just read the "index vals" property to get the array element and parse the coordinates to get the cluster element.
btw: the small while loop on the right serves no purpose at all and acts just as a CPU burner. You can delete it without any change in functionality. Is there anything else to it?
LabVIEW Champion . Do more with less code and in less time . -
Array of clusters and in the cluster is a bar meter, how can I change the color of the bar meter individually for each element of the array? I have just figured out that you can't change properties of one element of the array without all elements changing. For the scaling I had to make numeric indicators for each tick of the scale so that each bar meter in the clustered array would have individual scales. I also had to do some math to scale each barmeter to display correct proportions from 0 to 100%. Now I'm stumped on the color of the bar meter. Basically, if the value goes over a setpoint, the bar meter needs to turn red. It has to be in an array to be infinitely scalable.
Thanks
Matt
Solved!
Go to Solution.You can't do that-
without a little trick.
You could consider laying a custom color box over the bar graph in the cluster you can set the color based on the value of the bar graph or even make a "Pseudo"- bar graph using a series of color boxes stacked to look lie a bar and changing values of the Color boxs from empty to full to red.
Here is an example to demonstrate
Jeff
Attachments:
Pseudo bar.vi 12 KB -
Brick Wall Problem: Array of Clusters, Size of array from reference
Good Morning Forums,
I have hit a brick wall with my application and I am hoping somebody can help!
I have an array of clusters of indeterminate size (the cluster is generic, data contained not relevant.).
Inputs to the VI are: a reference to the array, and a variant containing the data.
My problem is I need to determine the array size from these two inputs and I cannot find a way to do it!
If the array contained a standard data type I can use the class name property to determine data type, and the size of the array returned from "select size" property to determine dimension size. With this information i can cast the variant into the correct data type and use this to determine the size of the array. If the data is a cluster the class name simply returns "cluster" so I cannot cast the variant and therefore am unable to determine the size.
I am not worried about casting the data (once i determine the size this bit is no issue), I just need to determine the size (and preferably number of dimensions) of the array. Can this be done?
Cheers for any help
J
John.P | Certified LabVIEW Architect | NI Alliance Member
Solved!
Go to Solution.John.P wrote:
Good Morning Forums,
I am not worried about casting the data (once i determine the size this bit is no issue), I just need to determine the size (and preferably number of dimensions) of the array. Can this be done?
Cheers for any help
J
There seem to be a couple of potential solutions.:
#1 if the varient is created within LabVIEW you can wite size(s) to a varient attribute. This would be pretty straightforward and easy to implement- I imagine you would have thought of that so you may not have access to the code writing cluster to varient and it gets a bit trickier.
#2 cast the varient to string and return string length- this should give you a measure of total size and you would need to know the size per element of cluster (just cast one instance of cluster array to varient and then to string with size and size++) but this only returns the total size of the array since nDim arrays are actually stored sequentially.
Hope this helped
Jeff -
Call library function node with array of clusters using array data pointer
Hello all.
I am writing a LabVIEW wrapper for an existing DLL function.
The function has, as one of its parameters, an array of structs. The struct is very simple, containing two integers. I am using the call library function node to access it.
In Labview I created an array of clusters, where the cluster has two 32-bit integers as its members. So far, so good.
Now I have to pass this in to the Call Library Function Node. Here I am running into trouble.
I have used The topic in LAVA and The topic in the knowledge base as my primary sources of information, though I have read a bunch of forum topics on the subject too.
I do understand that I could write a new function which takes as a parameter a struct with the size as the first member and an array as the second, and I might just do this and have it call the regular function, but I was hoping to do it more simply.
According to the C file which LabVIEW generates for me from the CLFN when I choose "Adapt to Type" and "Array Data Pointer", the prototype it is expecting is:
int32_t myFunc(uint32_t handle, uint16_t channel,
int32_t FIFOnumber, void data[], int32_t numWords, int32_t *actualLoaded,
int32_t *actualStartIndex);
And the prototype of the function in my DLL is
int borland_dll myFunc(DWORD handle, usint channel,
int FIFOnumber, struct mStruct *data, int numWords, int *actualLoaded, int *actualStartIndex);
This looks like a match to me, but it doesn't work (I get garbage in data). From the topic in LAVA referenced above, I understood that it would work. It does not.
If I cast data to the pointer-to-pointer I get when I generate c code by wiring my struct to a CIN and generating, then I seem to get what I expect. But this seems to work when I choose "pointers to handles" too, and I would expect array data pointer to give a different result.
Is there any way to get this to work directly, or will I have to create a wrapper? (I am currently using LabVIEW 2011, but we have customers using 2009 and 2012, if not other versions as well).
Thank you.
Batya
Solved!
Go to Solution.OK, here is more detailed information.
I have attached the VI.
This is the code from the "C" file created by right-clicking the CLN and creating a "C" file.
When the parameter in the CLN is set to "array data pointer":
/* Call Library source file */
#include "extcode.h"
int32_t Load_Transmit_FIFO_RTx(uint32_t handle, uint16_t channel,
int32_t FIFOnumber, void data[], int32_t numWords, int32_t *actualLoaded,
int32_t *actualStartIndex);
int32_t Load_Transmit_FIFO_RTx(uint32_t handle, uint16_t channel,
int32_t FIFOnumber, void data[], int32_t numWords, int32_t *actualLoaded,
int32_t *actualStartIndex)
/* Insert code here */
When the parameter is "pointers to handles":
/* Call Library source file */
#include "extcode.h"
/* lv_prolog.h and lv_epilog.h set up the correct alignment for LabVIEW data. */
#include "lv_prolog.h"
/* Typedefs */
typedef struct {
int32_t control;
int32_t data;
} TD2;
typedef struct {
int32_t dimSize;
TD2 data[1];
} TD1;
typedef TD1 **TD1Hdl;
#include "lv_epilog.h"
int32_t Load_Transmit_FIFO_RTx(uint32_t handle, uint16_t channel,
int32_t FIFOnumber, TD1Hdl *data, int32_t numWords, int32_t *actualLoaded,
int32_t *actualStartIndex);
int32_t Load_Transmit_FIFO_RTx(uint32_t handle, uint16_t channel,
int32_t FIFOnumber, TD1Hdl *data, int32_t numWords, int32_t *actualLoaded,
int32_t *actualStartIndex)
/* Insert code here */
When the parameter is set to "handles by value":
/* Call Library source file */
#include "extcode.h"
/* lv_prolog.h and lv_epilog.h set up the correct alignment for LabVIEW data. */
#include "lv_prolog.h"
/* Typedefs */
typedef struct {
int32_t control;
int32_t data;
} TD2;
typedef struct {
int32_t dimSize;
TD2 data[1];
} TD1;
typedef TD1 **TD1Hdl;
#include "lv_epilog.h"
int32_t Load_Transmit_FIFO_RTx(uint32_t handle, uint16_t channel,
int32_t FIFOnumber, TD1Hdl *data, int32_t numWords, int32_t *actualLoaded,
int32_t *actualStartIndex);
int32_t Load_Transmit_FIFO_RTx(uint32_t handle, uint16_t channel,
int32_t FIFOnumber, TD1Hdl *data, int32_t numWords, int32_t *actualLoaded,
int32_t *actualStartIndex)
/* Insert code here */
As to the DLL function, it is a bit more complicated than I explained above, in the current case. My VI calls the function by this name in one DLL, and that DLL loads a DLL and calls a function (with the same name) in the second DLL, which does the work. (Thanks Rolfk, for helping me with that one some time back!)
Here is the code in the first ("dispatcher") DLL:
int borland_dll Load_Transmit_FIFO_RTx(DWORD handle, usint channel, int FIFOnumber, struct FIFO_DATA_CONTROL *data, int numWords, int *actualLoaded, int *actualStartIndex)
t_DispatchTable *pDispatchTable = (t_DispatchTable *) handle;
int retStat = 0;
retStat = mCheckDispatchTable(pDispatchTable);
if (retStat < 0)
return retStat;
if (pDispatchTable->pLoad_Transmit_FIFO_RTx == NULL)
return edispatchercantfindfunction;
return pDispatchTable->pLoad_Transmit_FIFO_RTx(pDispatchTable->handlertx, channel, FIFOnumber, data, numWords, actualLoaded, actualStartIndex);
borland_dll is just "__declspec(dllexport)"
The current code in the DLL that does the work is:
// TEMP
typedef struct {
int control;
int data;
} TD2;
typedef struct {
int dimSize;
TD2 data[1];
} TD1;
typedef TD1 **TD1Hdl;
// END TEMP
int borland_dll Load_Transmit_FIFO_RTx(int handlertx, usint channel, int FIFOnumber, struct FIFO_DATA_CONTROL *data, int numWords, int *actualLoaded, int *actualStartIndex){
struct TRANSMIT_FIFO *ptxFIFO; //pointer to transmit FIFO structure
usint *pFIFOlist; //pointer to array of FIFO pointers to FIFO structures
int FIFOentry, numLoaded;
usint *lclData;
usint nextEntryToTransmit;
// TEMP
FILE *pFile;
int i;
TD1** ppTD = (TD1**) data;
TD1 *pTD = *ppTD;
pFile = fopen("LoadFIFOLog.txt", "w");
fprintf(pFile, "Starting Load FIFO with %d data words, data pointer 0x%x, with the following data: \n", numWords, data);
for (i = 0; i < numWords; i++) {
fprintf(pFile, "%d: control--0x%x, data--0x%x \n", i, data[i].control, data[i].data);
fflush(pFile);
fprintf(pFile, "OK, using CIN generated structures: dimSize %d, with the following data: \n", pTD->dimSize);
for (i = 0; i < numWords; i++) {
fprintf(pFile, "%d: control--0x%x, data--0x%x \n", i, pTD->data[i].control, pTD->data[i].data);
fflush(pFile);
// END TEMP
if ((handlertx) <0 || (handlertx >= NUMCARDS)) return ebadhandle;
if (cardrtx[handlertx].allocated != 1) return ebadhandle;
pFIFOlist = (usint *) (cardrtx[handlertx].segaddr + cardrtx[handlertx].glob->dpchn[channel].tr_stk_ptr);
pFIFOlist += FIFOnumber;
ptxFIFO = (struct TRANSMIT_FIFO *)(cardrtx[handlertx].segaddr + *pFIFOlist);
//use local copy of ptxFIFO->nextEntryToTransmit to simplify algorithm
nextEntryToTransmit = ptxFIFO->nextEntryToTransmit;
//on entering this routine nextEntryToLoad is set to the entry following the last entry loaded
//this is what we need to load now unless it's at the end of the FIFO in which case we need to wrap around
if ( ptxFIFO->nextEntryToLoad >= ptxFIFO->numEntries)
*actualStartIndex = 0;
else
*actualStartIndex = ptxFIFO->nextEntryToLoad;
//if nextEntryToLoad points to the last entry in the FIFO and nextEntryToTransmit points to the first, the FIFO is full
//also if nextEntryToLoad == nextEntryToTransmit the FIFO is full and we exit without loading anything
if (( (( ptxFIFO->nextEntryToLoad >= ptxFIFO->numEntries) && (nextEntryToTransmit == 0)) ||
( ptxFIFO->nextEntryToLoad == nextEntryToTransmit)) && (ptxFIFO->nextEntryToLoad != INITIAL_ENTRY)){
*actualLoaded = 0; //FIFO is full already, we can't add anything
return 0; //this is not a failure, we just have nothing to do, this is indicated in actualLoaded
numLoaded = 0;
lclData = (usint *)data; //must use 16 bit writes to the module
//conditions are dealt with inside the for loop rather than in the for statement itself
for (FIFOentry = *actualStartIndex; ; FIFOentry++) {
//if we reached the end of the FIFO
//if the module is about to transmit the first element of the FIFO, the FIFO is full and we're done
//OR if the module is about to transmit the element we're about to fill in, we're done - the
//exception is if this is the first element we're filling in which means the FIFO is empty
if ((( FIFOentry >= ptxFIFO->numEntries) && (nextEntryToTransmit == 0)) ||
((FIFOentry == nextEntryToTransmit) && (FIFOentry != *actualStartIndex) )){
*actualLoaded = numLoaded;
//set nextEntryToLoad to the end of the FIFO, we'll set it to the beginning next time
//this allows us to distinguish between full and empty: nextEntryToLoad == nextEntryToTransmit means empty
ptxFIFO->nextEntryToLoad = FIFOentry;
return 0;
//we reached the end but can continue loading from the top of the FIFO
if ( FIFOentry >= ptxFIFO->numEntries)
FIFOentry = 0;
//load the control word
ptxFIFO->FifoData[FIFOentry * 3] = *lclData++;
//skip the high of the control word, the module only has a 16 bit field for control
lclData++;
//now put in the data
ptxFIFO->FifoData[(FIFOentry * 3) + 2] = *lclData++;
ptxFIFO->FifoData[(FIFOentry * 3) + 1] = *lclData++;
numLoaded++;
//we're done because we loaded everything the user asked for
if (numLoaded >= numWords) {
*actualLoaded = numLoaded;
ptxFIFO->nextEntryToLoad = FIFOentry+1;
return 0;
//if we reached here, we're done because the FIFO is full
*actualLoaded = numLoaded;
ptxFIFO->nextEntryToLoad = FIFOentry;
fclose (pFile);
return 0;
As you can see, I added a temporary diagnostic with the structures that were created in the "Handles by value" case, and print out the data. I see what is expected, whichever of the options I pick in the CLN!
I understood (from the information in the two links I mentioned in my original post, and from the name of the option itself) that "array data pointer" should pass the array of data itself, without the dimSize field. But that does not seem to be what is happening.
Batya
Attachments:
ExcM4k Load Transmit FIFO.vi 15 KB -
Keyboard "tab" control in Array of Clusters
I'm trying to polish some of my LabVIEW user interfaces so that my users can work faster in them and so that they follow more "Windows UI Standards" (or whatever).
I have an array of clusters. The cluster has 3 numerics.
When a user "focusses" on the first numeric within a cluster and hits the tab key, it moves the focus to the second numeric. Hit tab again, and it jumps to the 3rd numeric. Hit the tab key a 3rd time and it jumps back to the first numeric in the cluster. What I want to happen is for the focus to move to the first numeric in the next element of the array.
I've started to play around with the "Key Down" event case that has a conditional looking for "TAB" and then checks the "FindCtrlWithKeyFocus" with the last numeric. My probes within this event show that the "TAB" key detection is working, but the "FindCtrlWithKeyFocus" never has a TRUE output from the "CtrlFound?" output of the Invoke Node.
Even if I did know if tab was pressed in the last element, I'm not real sure how to move focus to the first numeric within the next cluster element of the array.
A numeric array behaves in the correct way. I could get the program working the way I want with a 2d array of numerics. However, each numeric has different data entry parameters and there is also a lost of "self documentation". I would like to find a solution because this has come up with other, more complex, array of clusters that would not be solveable with a 2d array of a base type.
Seems overly complicated to me.
Bonus Question: The default value of my numerics is 0. When my user clicks a numeric the cursor is on either side of the 0 and the user has to delete the 0 prior to their data input. When a numeric is entered via the Tab key, the whole field is selected. When the whole field is selected, whatever the user inputs will replace the original "0" that was in the field. Anyway to have the whole field selected when the user uses the mouse?
Sorry for the wall-of-text post (and the preposition hell). Thanks for your input.
Solved!
Go to Solution.Well I've gone and gotten the tabbing behavior you're looking for.
-the key is to set "skip when tabbing" on the controls inside the clusters to true, and leave it false for the array elements. Now when keyfocus is on one of the cluster controls and Tab is pressed, LV will put the keyfocus on the next visible array element.
-then use a "key down?" filtering event to check and see if any of those controls have keyfocus when Tab is pressed. If so, and it's not the last control in the cluster, discard the keypress and programmatically advance keyfocus to the next item.
-Finally if the Tab press was not discarded, use a normal "key down" UI event to check if one of the array elements now has keyfocus and if so, set KF to the first control in its array.
So in short, this setup turns off tabbing along a row so that every tab will move to the next row. Then it filters out Tab if it's not yet at the end of the row. Finally, it automatically puts the cursor in the first column when the row has advanced.
One significant drawback is that it only tabs between visible array elements. You can probably make it auto scroll.
I'll leave it as an exercise for the reader to handle the shift+Tab (reverse tabbing) key presses.
To me, this runs up against three holes in LV UI programming:
1) Array Element events should be available. The Array:Key Down event only handles key presses when the array has keyfocus, not when things inside it do. Any kind of key filtering has to be done at the VI level (!!!).
The data source for these events should include the element index (eg what cell was clicked on?)
2) There aren't effective ways in VI server to deal with individual array elements. I recognize that some of it is the basis that array elements have the same properties, but there are display and selection properties that do differ between cells. I ought to be able to specify that a particular cell index has keyfocus. Arrays, why can't you be more like Tables?
3)Tab order should be flat, not hierarchical.
edit: in case the snippet messes things up, file is attached.
-Barrett
CLD
Attachments:
Tab through cluster array elements.vi 28 KB -
Array Of Clusters Not Initializing or Possible Race Conditions
Hi all,
I've been working on a fairly complex project for work, and I haven't worked with Labview before. Unfortunately nobody in my office really has experience with it so I'm on my own. I've mostly got the project working, and it might be a little cumbersome, but if it works that's fine.
Essentially it's a temperature control device and I made it so it's expandable, thus the clusters and arrays everywhere.
My question is this. I've got an array of clusters indicating the status of all the plates in the system. When I start up the VI for the first time they do not initialize. They just stay grey, but when I stop it and start it once, it will work every time. I think this is kind of strange behavior. I've heard of race conditions and while I've tried to make sure t hat's not happening, it might be without me noticing.
I've tried putting an initialize array block in the first call while loop and that doesn't do anything, and if I remove the initializer from the shift register in the top while loop that stops them being initalized altogether.
I guess I was hoping someone might have an idea what's causing it, or could possible give my code the once over. The main bulk of it is in the very top of the code, but there are a lot of smaller events taking care of GUI type stuff.
I've included all source code. It might be a little much but I didn't want to start pulling it apart if I don't know what's happening.
Thanks in advance.
Chris.
Solved!
Go to Solution.
Attachments:
Error During Cycle Controls.zip 3107 KB
Stop Cycle Controls.zip 2115 KB
Stop Cycle Controls.zip 4975 KBChris Johnson wrote:
So just to confirm, I can have one event structure with say 10 events happening? In this case could an event happen simultaneously with another? I thought I read something about each event having it's own event structure and while loop to make sure this works out.
Each event case must complete before it can handle the next event, but many events will complete so quickly that this is not an issue (such as your "pause chart" button). In general you should have only one event loop. If you expect an event to take a long time to process, use a queue to hand that task off to another dedicated-purpose loop, so that the event structure can go back to waiting. This is one example of the producer-consumer structure often mentioned on this forum: the producer is the loop containing the event structure, and it queues (produces) items to process. A separate loop dequeues (consumes) those items and handles them appropriately.
As GerdW mentioned, you have race conditions all over the place. You'll never know whether the Plate Info Cluster Array is properly updated because it's being written and read simultaneously in so many places. I'm assuming that is also where you're seeing the issue that inspired the post, and, in fact, one of those race conditions could explain what you're seeing.
Chris Johnson wrote:
Also, again, to confirm what I think I already know. When the event completes it outputs whatever data you output from the structure and then you can place it in a shift register. Where does this go until the next event takes place?
I don't understand what you're asking. Where does what go until the next event? If by this you mean the data in the shift register - it stays in the shift register, accessible at the corresponding terminal on the left side of the loop. -
Cannot set Flash button properties from sprite behaviour
I'm puzzled...
I'd like to set Flash button properties from behaviors on the
sprite
itself (unselect all buttons with a sendAllSprites, for
example) but
only this sample script works :
on mouseEnter me
sprite(spriteNum).selected = true
end
those ones won't:
on mouseEnter me
me.selected = true
end
on mouseEnter me
selected = true
end
It must but obvious but I can't get it to work...
Thanks.
PJThe selected property is a property of the sprite. You need
to
reference the sprite specifically when you access it.
When you are using
me.selected=true
the 'me' is referring to the current instance of the
behaviour that is
running. It is not referring to the sprite itself. Therefore,
you need
to use
sprite(me.spriteNum).selected=true
so that you correctly reference the sprite.
You can use the syntax
me.property=true
only if the property in question is a property in that
*script*. -
Update a slider insider an array of clusters
I have an array of clusters. Each clusters has several controls, one of
which is a slider. I want to change the scale of the slider
dynamically, since I have one slider per variable in my system. I'm
using a for loop to access each cluster in the array and update the
scale of the slider to match the range of the variable. But when doing
this, the scales in all the sliders are updated at once, thus all
sliders end up having the range of the last variable.
Is there a way to avoid this automatic update of all the elements in an array?In the unlikely chance that your array size is fixed you could work with a cluster of clusters
You can then use the Controls[] property to access the individual maximum and scales property nodes.
Incidently I had seen this before http://forums.ni.com/ni/board/message?board.id=170&message.id=170076&query.id=49401#M170076. There are some tips on how to get around the array to cluster limitations. They might apply to you.
David
Message Edited by David Crawford on 06-21-2006 07:53 AM
Message Edited by David Crawford on 06-21-2006 07:53 AM
Attachments:
Cluster Of 5.jpg 31 KB -
Creating buttons on the fly and setting button properties
If I have a view and want to add buttons to it "on the fly" from values in an array, is that something straightforward to do?
I have an array of UIImageVIew objects and would like to create buttons from them (showing the image on the buttons) and associate those buttons with a method in my implementation file. That would be a lot more general and flexible than creating the buttons in the Interface Builder I would imagine.
And one more question - can I freely set button properties while doing that? Or in Objective-C can I only set properties that are already pre-defined for that class?
Thanks!
dougThanks for your reply.
That.... works! Thanks!
And I can generate the button and click on it and it calls my other method and that works too. Cool!
The syntax is still very mysterious to me, but I suppose eventually I'll understand what it all means.
Breaking it down to see what it means:
[button1 addTarget:self action:@selector(selectedHandler1:) forControlEvents:UIControlEventTouchUpInside];
* button1 is the object I created (I'm going to try to do this in a loop next.)
* addTarget is a message I am sending to button1 and the content of the message is "self", which refers to - this button? I'm not sure why such a message would be necessary.
* action is another message sent to button1 and the contents of that message are a little harder to parse. I see the result, and can mimic the syntax now that I've seen it, but I don't really understand what the @ is for, or the : after the method name or why this wouldn't just be "action: selectedHandler". I'm sure the language designers have a logical reason for all that, but I don't quite "grok" those extra symbols yet.
* forControlEvents is another message sent to button1 and the event message itself is clear in its meaning.
Anyway, that is working and I can refer more to the UIButton class reference now and try to set more stuff, like position it better, etc.
Thanks very much!
doug
Maybe you are looking for
-
After I updated my early2008 macbook to os10.7.5, Safari keeps telling me it quit unexpectedly every time I try to open then program. It never even brings up the safari window. It just instantly goes to the "safari quit unexpectedly" box. Any ideas?
-
hi ive put my ee sim card in my iphone 5 and its keeps coming up activation required can anybody help me
-
URL Not Changing Session State Variables Specified
I am trying to change a variable on a target page with a URL, however, the variable never changes. The variable is set to 8. I send the following URL which should change it to 0 but it does not change. We just recently upgraded to 1.6 Why is this not
-
SB Live! 5.1 (sb0100) software probl
Hi. I got recently a SoundBlaster Li've 5. (code SB000), with original software CD, but when I tried to install it, things gone wrong. First of all I use WinXP pro sp2, and when I installed the card, it found itself the drivers, but I wanted to try t
-
How to import passwords on windows vista
firefox wont save password for facebook i am using windows vista any help please