call a function to listener programmatically

I have a function that is called on a ListEvent. I want to call it programmatically on the startup of the program as the default even if the user has not triggered the event.

How can I do this?

var tmpE:ListEvent = new ListEvent;
tmpE.index = 0;

onItemSelected(tmpE);

private function onItemSelected(e:ListEvent):void {
      // some code
}

It is called and it works very well when the event is raised, but I would like the event to be triggered or call the listener automatically function at startup.

Dave

Thanks for the responses... Sorry to be a clear, I was really tired when the post was created.

I want to be clicked on the list box (blue list as a user has clicked on it by default)

I call the function of default listener like this:

var tmpE:ListEvent = new ListEvent("listItemClicked", null, 0, 0, 0, 0, null);
onItemSelected(tmpE);

and he calls this function to listener:

private function onItemSelected(e:ListEvent):void {
    if (currentList) {
        rightContainer.removeChild(currentList);
        currentList = null;
    }

    trace ("cell:" + e.cell + " data:" + e.data);

    switch (e.index) {
        case 0:
            trace("About");
            buildAbout();
            break;
        case 1:
            trace("General");
            break;
    }
    if (currentList) {
        rightContainer.addChild(currentList);
        rightContainer.layout();
    }
}

The listener function works perfectly if the user selects a list item, it relies also the default option at the start of the first section of code without problem, but the words or the first item in the list is not selected.

When the program loads the first item by default, it is not obvious to the user that the first item in the list is already loaded and selected because the list item is not selected...

Thanks for your help guys.

@pyth... use it in future thanks.

Tags: BlackBerry Developers

Similar Questions

  • Headphones - a framework-entering and leaving a frame to call a function

    OK, I try to get the following functions to load and unload the video on my main calendar when I go in and out of a frame. I tried on Enter_FRAME, but it works fine now and load many cases.

    What are the headphones I do call the oCoach functions when enetering a framework and fclickCV when you leave a framework? Thanks in advance!

    //========Scenario Movie===================
    var pCoach:coach_mc = new coach_mc();
    var spriteCoach:Sprite= new Sprite();
    spriteCoach.x = 5;
    spriteCoach.y = 30;


    //----------open scenario---------
    function oCoach(myevent:MouseEvent):void{
         stage.addChild(spriteCoach);
         spriteCoach.addChild(pCoach);
        pCoach.myVideo = myVideo1;
         pCoach.my_ns.play(myVideo1);
         coach_btn.visible = false;
    //     pCoach.scenario_txt.htmlText = myScenario;
    }
    stage.addEventListener(Event.ENTER_FRAME,oCoach);
    //coach_btn.addEventListener(MouseEvent.CLICK,oCoach);

    function fclickCV(myevent:MouseEvent):void{
         coach_btn.visible = true;
         pCoach.my_ns.close();
         stage.removeChild(spriteCoach);
         pCoach.removeChild(videoVO);
         pCoach.clearInterval(loaded_interval);
    }

    pCoach.closeCoach_btn.addEventListener(MouseEvent.CLICK,fclickCV);
    forward_btn.addEventListener(MouseEvent.CLICK,fclickCV);
    back_btn.addEventListener(MouseEvent.CLICK,fclickCV);

    enterFrame and exitframe are loops.  they aren't events once as their name suggests.

    to run code by entering in a frame, set the code to the framework or, better, create a function that contains the code and call this function of the frame.  to run code to the output of an image, create an object that is removed from the display list when you exit the frame.  You can then apply the removedfromstage a listener to the object to call a function that runs when you exit the frame.

  • Can I call a function using the array index?

    I defined a table that stores the name of the function, like this:

    var aresetButtonTop:Array = new Array(resetTop1,resetTop2,resetTop3,resetTop4,resetTop5);

    Then I have a button named "btnresetTop" which, once clicked will be called one of the five functions stored in the array (aresetButtonTop) above. Functions are called at runtime depending on certain conditions. I need to figure out how I can call these functions using the array index. I use the following code to call the function. The value of i has already been calculated.


    btnresetTop.addEventListener (MouseEvent.CLICK, aresetButtonTop [i]);

    After doing this, I get the following error when I click on the button:

    TypeError: Error #2007: parameter listener must be non-null.
    at flash.events::EventDispatcher/addEventListener()
    at gallerytest_fla::MainTimeline/thumbTopClick()

    Note: thumbTopClick() is a function within which all these codes are written.

    I need to know if it is posible in AS3 to call a function name using array index or not. If so, could you afford ehelp me out.

    You can certainly do.

    In your case, it looks like i is out of range. Show your loop.

  • Is it possible to call a function in a parent of a child component component in Flex 3?

    It is probably a very basic question, but ask for this for awhile.

    I need to call a function in a parent component and the appeal of its child element in Flex 3. Is there a way to access an element functions of the child element parent? I know that I can send an event for children and add a listener in the parent to call the function, but just wanted to know if could also directly call a function of parent of a child (similar to how you can call a function in the main mxml file using Application.application). Thank you

    There are no performance issues, but it's ok if you use the child component in a single category. Suppose that you want to use the same component as a child to a lot of parents then if all the following

    public interface IParentImplementation{
    
         function callParentMethod();
    }
    

    and the parent of the class has to implement this 'IParentImplementation '.

    usually to the next line

     public class parentClass extends Canvas implements IParentImplementation{
              public function callParentMethod():void{
         //code
              }
         }
    

    in children, you should do something like that.

    (this.parent as IParentImplementation).callParentMethod();
    

    Here the use of Interfaces, we're to decouple the parent and child

    If this post answers your question or assistance, please mark it as such.

  • Call or function of the class from a loaded MC

    Hello

    Can someone tell me if its possible to call a function or a class from a loaded MC?

    mainMovie charge MC > MC calls the function in a class of mainMovie

    If so, what is the best method?

    I tried this loaded MC but (of course) an error:

    movieClip (parent.parent). DO_THIS();

    Thanks for everything 'light' on this.

    Have the loaded SWF file send a custom event that spreads and listen to this event in the parent.

    In SWF loaded:

    dispatchEvent (new Event ("customEvent", true));

    Parent:

    addEventListener ("customEvent", handleCustomEvent);


    function handleCustomEvent(event:Event):void

    {

    do your stuff in the parent here
    }

    TS

  • How to implement a callback to the help function call library function node in LabView?

    I try to call a fuction from a SDK.dll library by using the node call library feature. The SDK has been provided to

    me and I don't have the source code, just the .dll and .h files.

    The SdkSetPropertyEventHandler function has a function of recall as one of its parameters. How to apply the

    callback using the NSI node? I'm a good programmer LabView but this is my first time using the library to call

    Function node. I read all the info I can find on the web site of NOR and the discussion Forum, but can not understand

    This one out. I'm using LabView 8.6.

    The deacribes SDK.h function as:

    Function: SdkSetPropertyEventHandler

    (SdkSetPropertyEventHandler) SdkError SDKAPI
    SdkCameraRef inCameraRef,
    SdkPropertyEvent inEvnet,
    SdkPropertyEventHandler inPropertyEventHandler,
    SdkVoid * context);

    //
    Description:
    Registers a callback function to receive the status
    change the notification events for the States of property on a camera.
    //
    Parameters:
    In: inCameraRef - designate the object camera.
    inEvent - designated one or all the events will be completed.
    inPropertyEventHandler - designate the pointer to the callback
    function to receive the camera property-related events.
    inContext - designated application information must be passed
    way to the callback function. All the data necessary to
    your application can be passed.
    Output: no
    //
    Returns: A sdk errors.
    -----------------------------------------------------------------------------*/

    A separate header called SDKTypes.h file contains the following data:

    typedef SdkUInt32 SdkPropertyEvent;
    typedef SdkUInt32 SdkPropertyID;
    typedef void SdkVoid;

    typedef struct __SdkObject * SdkBaseRef;
    typedef SdkBaseRef SdkCameraRef;

    /*-----------------------------------------------------------------------------
    SdkPropertyEventHandler
    -----------------------------------------------------------------------------*/
    typedef SdkError (SDKCALLBACK * SdkPropertyEventHandler))
    SdkPropertyEvent inEvent,
    SdkPropertyID inPropertyID,
    SdkUInt32 inParam,
    SdkVoid * context);

    Thanks for your help.
    Alejandro

    Andrew_E wrote:

    Hi Rolfk,

    You are absolutely right. This article describes what you were talking about? I'm just trying to get as much information as possible on this thread if the solution is easier to find for the future. Thank you.

    Yes, but I find the idea of using .net to call a LabVIEW VI as callback function C a bit as using a roll of Steam ironing your pants. Why do it? Well the steamroller has extra security guards that make it less likely that you'll break your pants in the process, but it's not elegant IMHO.

    Write a C DLL that translates between a C callback and a user event LabVIEW using the PostLVUserEvent() of the interface of the kernel to run LabVIEW function seems so eleganter for me. Yes, it's a bit of programming in C, but good!

    Rolf Kalbermatter

  • Call library function node

    When using a call library function node, and the program came out, I get an error "has encountered a problem and needs to close" having to do with ntdll.  It does not stop the program from running properly, but it's annoying.  Any ideas?

    You should NOT specify the full path to a DLL system in the configuration dial the node of the library. This mess something in the newer versions of Windows. Instead just enter the name of the DLL only. It is sort of a bug in LabVIEW not automatically detect the system paths and shorten the path accordingly in itself, but this is how things have been for a long time and you just need to be a little careful.

    Also the return value must be really set up to be an integer of size of pointer, since a HANDFUL is really a pointer under Windows and that the first parameter is also better configured as such. The way you did works very well for LabVIEW 32 Bit but will misbehave in LabVIEW 64 Bit.

  • What is the right way to specify the location of the shared library in an a .lvlib function call library function node?

    I'll have a bit of a problem with how to specify the location of library shared in a call library function node it is a VI that is part of a library of LV. Here's a little background which may help.

    I do a lot of measures using spectrometers photo from several manufacturers.  Someone in my company developed a C DLL library, which provides a simple API for all the different spectrometers. To facilitate this DLL to use in LabVIEW, I wrote a .lvlib that wraps all the functions.  When I want to use the API, I simply include the .lvlib file in my project that allows me to drag and drop the wrapper s VI on my block diagram. When I created the .lvlib of VI, I specified the path in the call library node. /. * so it will always look in the local application to the DLL directory when I run.

    The problem is, when I load demand, LabVIEW you asks for the location of the DLL even if it's just there in the local directory! I tried to put copies of the DLL in the directory with the .lvlib, but he still refuses to find the DLL loading.  What I am doing wrong?

    You should in this simple case enter the full path to the DLL by navigating to it. If the DLL is on the same volume/drive that the VI containing the call library node LabVIEW will be internally store the relative path from the VI to the DLL (but still show the absolute path). If you move the DLL and screw together (so the relative location of the DLL to the VI remains the same) LabVIEW will always find the DLL.

    I don't think that the lvlib would add nothing to that.

  • Crash when moving from a structure in a call library function node

    I am trying to use a type of Fortran (which I think is similar to a struct) in a LabVIEW call library function node.  I read a few remedies to this topic, but I'm not quite sure if I need to add the name of the parameter list of the node structure.  Now, when I run my VI it closed just LabVIEW entirely with no message.  I've attached the VI that I use and code source fortran, which compiles in my .dll.

    Any help is appreciated.

    Do you know if Fortran passes parameters by value or by reference?  I never used it.  A very quick search on the internet gives to think that the parameters must be passed by reference.  If this is the case, then you must pass the entire cluster as the parameter single, similar to Fortran statement.  You must also change the order of cluster to match the order in the Fortran statement.  Try the attached VI.

  • Call the function in LabView from a DLL, and then access the global variable of DLL

    I've created a DLL in LabWindows with a function and structure.  I want to call the function from LabView and then access the overall structure.  I am able to call the function in the DLL with a "call library function node" and has access to the return value, but I can't understand how to access the overall structure.  The structure is declared in the header DLL with __declspec (dllimport) struct parameters file.

    Is it possible to access this structure without using the library of network variables?

    My guess is that you need two bytes of padding after "in_out" and another to two bytes of padding after "anin."  The reason being that ints are 4 bytes, and most of them C compilers will align on 4-byte boundaries.  The struct will naturally start to such a limit (in fact, in Windows, it will probably start to an 8 byte boundary).  If you then count bytes in your structure, you are 70 byte after "in_out."  70 is not divisible by 4, so you need 2 bytes more to reach the next 4 byte boundary.  You can also you could reorganize your struct so that "anin" follows "in_out" and this is probably the best option if it won't cause you other problems.

    Unlike most C compilers, LabVIEW compressed structures as closely as possible, without filling.  I don't know enough about the history of LabVIEW and internal parts to explain the reasons and to do this performance penalty, but, as choice of LabVIEW "endianness", it is probably a remnant of the first versions of LabVIEW that were running on the Mac.

    If for some reason you want to force your C struct to match package LabVIEW, you can use the #pragma pack (x) directive, but I wouldn't recommend that here because you can control the C and LabVIEW.

    EDIT: in the cases where it was not clear, add padding to your cluster of LabVIEW, insert appropriate size or items at the place desired in the cluster.

  • help with call library function node

    I have problem with node function call library that I try to use velleman k8061 dll file to get this working labview

    all I'm trying to get the same problem

    but I chose one to explain it

    SetDigitalChannel
    Syntax
    PROCEDURE SetDigitalChannel (CardAddress: Longint;) Channel: Longint);
    Parameters
    CardAddress: The address of the previously opened card.
    Channel: Value between 1 and 8, which corresponds to the output channel to be resolved.
    Description
    The selected digital output channel is activated.
    Example of
    BEGIN
    SetDigitalChannel (0, 1);

    now, when I try to call the function of library in k8061.dll node and set up 2 a card address and one for the channel

    address of card type: type numeric & statistics: signed 32 bit intger

    channel type: numeric type & data: signed 32 bit intger

    function prototype

    void setdigitalchannel (int32_t, intg32_t channel address);

    I also configure error call library function node checking up

    now that I run it, I get error 1517 produced and tell me this mismatch between the calling conventions?

    problem solved

    thanx

  • How to identify which switch in the Panel called the function?

    Here I have some 192 switches and 192 leds corresponding to each switch,

    If a switch is on(say 10th) consequence (10th) led should light up.

    I want to use the same function for all pairs of led switch.

    all I could do was to check the switch in a loop and then set the individual leads, but I find it very little effective way to do it.

    int switchOnOff (int, int int event control panel CVICALLBACK,
    void * callbackData, int eventData1, int eventData2) is the function.

    None of these arguments I can use it to extract what (the unique id for this turnout) switch called the function so that I can pass corresponding led glow?

    It occurred to me now that the table is not necessary at all: you can simply assign to each switch the corresponding ID led the callbackData, so that the code is even simpler than my previous:

    // At panel load:
    SetCtrlAttribute (panelHandle, PANEL_SWITCH1, ATTR_CALLBACK_DATA, (void *)PANEL_LED1);
    ...
    SetCtrlAttribute (panelHandle, PANEL_SWITCH192, ATTR_CALLBACK_DATA, (void *)PANEL_LED192);
    
    // In the control callback
    GetCtrlVal (panel, control, &sts);
    SetCtrlVal (panel, (int)callbackData, sts);
    

    To answer your last question, "Management Board" means immediately after the call to LoadPanel.

  • call library function node - function not found

    When you create a DLL, I get a error Labview "node"LabviewReceiverDLL.dll:readDataJ1939Data "function not found." call library function Everything looks good to me and cela used to work, even if I changed computers since then.

    This is the beginning of my C++ code just to show my name of the function. I've also attached the function of the library calls window to show my setup.

    Thanks in advance for your help.

    #include "StdAfx.h"

    #include

    / * Call library source file * /.

    extern "C" __declspec (dllexport) unsignedint readDataJ1939Data (unsignedint, unsignedint, unsignedchar, unsignedchar * canData, unsignedchar path);

    unsigned int readDataJ1939Data (ulTimeStamp, ulIdentifier, unsignedchar uiDataCount, unsigned char unsignedint unsignedint * canData, constchar path)

    {

    I've recreated the DLL and Labview library node call and now it works.

  • call library function node to paste files

    Hello, I use the call library function node to paste the text to and from the Clipboard and works well.  Now, I'm trying to figure out how to paste a file from the windows file Explorer.  So if I highlights a file in the Windows File Explorer and press Ctrl-C, how can I use the library function node spit a file path?  It would be even better if I could highlight a bunch of files and then paste a table of paths, but that can wait.  Also, I use a Listbox MC, so I can't use drag-and - event trigger move a control path of the file.

    Also, I use WinXP and LV 7.1.

    Thank you

    Pat

    UPDATE

    I had little time to play with it and really out of curiosity on my part that I have whipped up a simple example to drag and drop from the Explorer in LabVIEW. I wrote the code in 7.1, but I have 7.1 on a virtual machine, and the DragQueryFiles did not work. I don't know if it was due to the fact that I was running on a virtual machine. I did, however, run the code in 8.2 and it works correctly. 8.2, I was able to drag a bunch of files in front of the VI, and the string table fills with file names. I am especially to see if it might work for you. You will need to get the Windows Message Queue library. Simply place the library in the same folder where you unzip the attached file.

  • Connection of several call library function node

    First of all, I apologize if some of these issues are pretty basic. For my work, I have been teaching myself LabVIEW (using one of the books) for the last two months, in addition to a course of semesters of C++ software development. I have flowed through a few examples from the book and have searched these forums + google search, but I found the contradictory and confusing information on how to manage the C string data.

    I have attached a photo of the block diagram, the real VI and a manual describing the .dll file I'll call you. My real application is more complicated than what I've built here (I installed a trial version free at home, since I can't bring my lab computers files due to their having no do not have access to the internet...) There install everything for us, but it's a side story!), but deals with execution other than that, as I have the VI wrapped around an imposing event that runs based on which side a user presses the button, messages pop up additional user, etc..

    In the end, I'll implement a program which allows a user presses a single button that sends a bunch of instructions to an instrument, where requested orders have been compiled by the society of the instrument in a couple of .dll files. The instrument itself be held the certain function specifications, so there is not much need to worry to get somewhere, out string parameters to be stored, and there is no reception data of the instrument: it simply distributes liquid charges based on what parameters I pass to it. Given the same internet connection problems, I have to wait a few weeks for my IT team installed a decompiler of .dll file on the computer that has installed LabVIEW so that I hope that I can directly import the header file in the Import Wizard. I worked out of their manual without even being able to look in the .dll file (which may be more documentation), and they do not have the more detailed documentation on their data types (even if maybe these data types are public knowledge, and I'm just missing something). I went ahead and copied + pasted some of their function prototypes + example code pages 16 and 17 of the provided pdf (it looks like to me a C calling convention):

    'Functions of the DLL to talk to the PiezoElectronics.

    Public Function declare bfx_piezo_OpenPort Lib "bfx_piezocontrol.dll" (ByVal portname As String) As Integer

    Public Function declare bfx_piezo_ClosePort Lib "bfx_piezocontrol.dll" () As Integer

    Public Function declare bfx_piezo_ConfigurePiezo Lib "bfx_piezocontrol.dll" (ByVal ability As Double, ByVal VoltagePerStroke As Double) As Integer

    Public Function declare bfx_piezo_SetupPiezo Lib "bfx_piezocontrol.dll" (ByVal StrokeLength As Double, ByVal DownStrokeVelocity As Double, ByVal HoldTime As Integer, ByVal UpStrokeVelocity As Double, ByRef LoadTime As Double, ByRef LoadCurrent As Double, ByRef UnloadTime As Double, ByRef UnloadCurrent As Double) As Integer

    ' Search for electronics

    RC = bfx_autodetect_SearchPiezo (False, PiezoElectronicsPort, PiezoElectronicsDev)

    If rc = 0 then MsgBox("No electronics could be detected", MsgBoxStyle.Critical)"error message LogLabel.Text ="no electronics could be detected.

    On the other

    Action.Enabled = True '

    Device found-> activate the button LogLabel.Text = "Piezoelectronics" found on the Port & PiezoElectronicsPort

    RC = bfx_piezo_OpenPort (PiezoElectronicsDev) ' establish communication

    If rc = 0 Then LogLabel.Text = "open e".

    End If

    End Sub

    Private Sub Action_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Action.Click

    Dim rc As Integer ' to store the return code of the dll

    Dim LoadTime, LoadCurrent, UnloadTime, UnloadCurrent As Double ' to store the values returned by the dll

    RC = bfx_piezo_ConfigurePiezo (PiezoCapacity, PiezoVoltagePerStroke) ' Tell the dll of the distributor of physics

    If rc = 0 Then LogLabel.Text = "Configured distributor" "configure the parameters of dosage

    RC = bfx_piezo_SetupPiezo (stroke, beat down, HoldTime, ascending, UnloadTime, UnloadCurrent, LoadCurrent and LoadTime) rc += bfx_piezo_Repeat (repetitions, RepeatDelay)

    If rc = 0 Then LogLabel.Text = "Setup dosage settings."

    Only four interested features me search piezo, open port, configure piezo and piezo installation, as seen on my block diagram. My questions concern only the setup functions / openport piezo and how I built the library call nodes function, since these would also address how to set up the other two. When running VI, I get the error code is 1517, with installation function highlighted, leading me to believe that I have this feature badly adjusted upward (and Potentially openport, explained in the next paragraph).

    Function to open the port has two string parameters that are passed by reference, and configure the function takes one of the following strings as a call by value. Can I just wire them together as I did, or is it necessary to do something in the sense of adding a sub - VI GetValueAtPointer to dereference firstly, the pointer to the string and then spend the actual string on the second node?

    To specify the data types in the function library call nodes, I have all channels like C strings, double as double, return numeric values as integers signed 32 (each function returns a digital long I think that for debugging purposes), Boolean as an integer 16 bit signed (after that I forced my Boolean constant in an integer) and one of my numbers in Setup as an integer no signed, as I was told in an e-mail from the manufacturer of the instrument. Should we indicate the call launched by numbers as constants value, or not, since they are not explicitly defined as constants in the code provided? Since they have been specified not as long, I am right to assume signed 16-bit integer for the passage by the digits of the value? Is the Boolean value a 8-bit or 16-bit and signed? If the function has a numeric parameter as a value call, I guess by the wiring in a digital constant, that this value is transferred to the function?

    Again, I apoligize if these questions are too simplistic (and many of them), due to my limited experience programming and possibly scarce documentation of the company during the inspection. I look forward comments about the VI as well, if I had nothing at all just illegal/bad practice.

    Thank you for your time!

    First of all, I'm really not familiar with C/C++ dll, but I remember something the DLL must contain the standard C functions to properly accessible from LabVIEW. I don't know if this is the case here, but lets see more will enlighten this part.

    Second, whenever I have the chance to directly use the simple series commands, I go like this, and I create my own live LabVIEW. As I see in the attached pdf doc, it is possible to order the material through the series without using the DLL (on page 18). If these features meet your needs, I would really screw via VISA program, your life will be much easier...

    Edit: http://www.ni.com/tutorial/3702/en/

Maybe you are looking for