Handling events in subvis - think this should work but it doesn't.

In part of a large project I need to handle key down events, but elsewhere I need to handle them differently and want to be able to dynamically register and unregister them in each location. I also want to be able to put one of the event handlers in a subvi. To quote the Help system, "Dynamically Registering Events: With dynamic registration, you can handle events in a subVI rather than only in the VI where the events are generated."
ViThatHandlesEvents.vi handles key down events. It uses dynamic event registration to demonstrate that it works (though in this simple example it isn't necessary).
ViContainingSubviThatHandlesEvents registers key down events and passes this to KeyDnEventHndlrSubVI. I thought it would work but it doesn't.
Attachments:
KeyDnEventHndlrSubVI.vi ‏14 KB
ViThatHandlesEvent.vi ‏22 KB
ViContainingSubviThatHandlesEvent.vi ‏18 KB

cebailey wrote:
Here's a version with Panel > OwningVI > Key Down selected in the nodes that register events. It seems to do what I want. It acts on keystrokes that occur when the cursor isn't even over the parent's window, which is good in my situation. I made these choices by experimenting - is this a good approach, if I want to act on all the keystrokes that occur when the parent VI has focus?
As you noted, this will have the event structure respond to keypresses whenever the parent VI is active. You can simplify the subVI by simply wiring the "VI Refnum" terminal directly to the Register for Events node. Getting the Panel, and then the Owning VI simply gets you back to where you started.
That's a valid way of doing it, and I'm assuming that this is intended to be a test case. As you noted you have a large project, so I don't know what your overall architecture is, or how you intend to use this technique, so I can't really say whether it's a "good" approach. It's an approach.
Say, I should have said this before, but you have to be pretty good to answer the question somebody should be asking, especially in brief forum postings.
Thanks for the compliment. It's just a matter of seeing a lot of code and a lot of questions. I'm only a teenage pup compared to the real veterans on this board.

Similar Messages

  • This should work but it doesn�t Please can someone tell me why !!!

    I have really trid to get this code to work.
    Please an some help me with find out why it will not work.
    void NewShoeOrderjButton_actionPerformed(ActionEvent e) {
       String check = TitleComboBox.getSelectedItem()+" "+FirstNameJText.getText()+" "+LastNameJText.getText();
       if (check !=null){
        return ;
        else
        String[] options = {"Yes", "Cancel"};
        String d= System.getProperty("line.separator");
        int result = JOptionPane.showOptionDialog(null,
            "Do you really want to add a new shoe order for:"+ d +
            (String) TitleComboBox.getSelectedItem()+" "+FirstNameJText.getText()+
            " "+LastNameJText.getText(),"New Order",
            JOptionPane.YES_OPTION,
            JOptionPane.INFORMATION_MESSAGE,
            null,
            options,
            options[0]);
        switch(result){
          case JOptionPane.YES_OPTION: // Add your code for no
            setFieldsEditable(false);
            break;
          case JOptionPane.NO_OPTION: // Add your code for yes
            // just playing with button
            setFieldsEditable(true);
            break;
      if
        (check ==null){
        return ;
        else{
          JOptionPane.showMessageDialog( null,
                                          "There is no order", "No Order",
                                         JOptionPane.WARNING_MESSAGE);
      }

    Thank you for taking the time mate ;)
    This is he code changed with your code.
    when the title,first &last name is null it still only runs the 1st JOptionPanel and dosn't pass to the 2nd ??
    here is the code
      void NewShoeOrderjButton_actionPerformed(ActionEvent e) {
        String check=null;
        if(TitleComboBox.getSelectedItem() != null &&
           FirstNameJText.getText() != null &&
           LastNameJText.getText() != null)
          check=TitleComboBox.getSelectedItem()+FirstNameJText.getText()+LastNameJText.getText(); //the rest of the thing.......;
    //then you check "check":
        if(check != null){
          //show the first optionpane
          String[] options = {"Yes", "Cancel"};
          String d= System.getProperty("line.separator");
          int result = JOptionPane.showOptionDialog(null,
              "Do you really want to add a new shoe order for:"+ d +
              (String) TitleComboBox.getSelectedItem()+" "+FirstNameJText.getText()+
              " "+LastNameJText.getText(),"New Order",
              JOptionPane.YES_OPTION,
              JOptionPane.INFORMATION_MESSAGE,
              null,
              options,
              options[0]);
          switch(result){
            case JOptionPane.YES_OPTION: // Add your code for no
              setFieldsEditable(false);
              break;
            case JOptionPane.NO_OPTION: // Add your code for yes
              // just playing with button
              setFieldsEditable(true);
              break;
        }else{
          //show the second optionpane
          JOptionPane.showMessageDialog( null,
                                         "There is no order", "No Order",
                                         JOptionPane.WARNING_MESSAGE);
      }

  • How do I change my user name in syn? I typed in the wrong email address. And I cancelled syn thinking this may work but no luck.

    How do I change my user name in syn? I typed in the wrong email address. And I cancelled syn thinking this may work but no luck.

    You have to clear saved password for this page:
    # Open you login page (where you have to enter username and password).
    # Right click on page and select '''Page Info''' form context menu.
    # On last tab ('''Security''') there is '''View saved passwords''' button, click it and delete all saved passwords for this page.
    # Also clear all related cookies (just in case) there is button for this next to first one.

  • MP-101 paper jams my MG3100 printer. Manual says it should work but it doesn't. Can someone help?

    Subject says it all.  I got MP-101 paper for my MG3100 printer.  The manual for the printer says this paper should work fine, But the printer fails to pull it all the way through and my printer jams.  Is this a typo in the manual, or is there some way to get it to work?  I set the printer to Photo paper on the actual printer itself, and choose "Matte Photo Paper" on media type inside the printer properties.

    Apple keeps your last 3 backups by making a complete backup of your device at the time of the backup, then keeping any changed files in case you want to restore to an ealier backup.  So it does, for the most part, overwrite the current backup.  However if your backup significantly increased in size it would have to allocate more space in order to maintain the ability to go back to your earlier backups.  An option to try if you don't care about maintaining the ability to go back, is to delete the existing backup.  This would delete the entire backup history and may clear enough space to create a fresh backup.  You wouldn't know unless you tried.

  • Thi should work but is not. (Longish code Sorry :))

    Hi I am using a ArrayList that can be set to various other arrayList values according to what commant is sent to the BL of my application. I know I am doing something wrong coz if I return the phonlist alone in my getList method by making the modifiedList equal to the phonelist i get the correct output. However I now try make the list variable equal to the phoneList in my createNew() and then i try set the modifiedList variable to the value of the list variable. It does not work.
    Declaration in class
    ArrayList<Person> phoneList = new ArrayList<Person>();               // To hold all the contacts
         ArrayList<Person> searchList = new ArrayList<Person>();               // To hold all contacts that return true on search
         ArrayList<Person> list = new ArrayList<Person>();
         final int maxLength = 10;                                                  // To be used as a boundary value for the Strings enteredWhere I set the list to be the value of the phoneList in my createNew()
    public void createNew()
         { // start of createNew()
              Person p = new Person();
              boolean validNewEntry = true;                                        // A boolean that determines if the ArrayList must be updated
              int count = 0;                                                            // Counter used in loop
              int homeNum, workNum, cellNum =0;                                   // To be used in a try statemant to test validity
              //Get new Contacts name
              String newName = JOptionPane.showInputDialog(null,"Please enter new contacts name or press cancel to exit.");
              if(newName == null)
                   finish();
              //If no name was enetered warn and try again
              if(newName.length() <= 0)
                   JOptionPane.showMessageDialog(null,"You may not enter a empty name. Please try again.","Error",JOptionPane.ERROR_MESSAGE);
                   validNewEntry = false;
                   createNew();
                   return;
              //If name was enetered and it's length was greater then 10 chars long
              //Retry and warn as this will lead to a faulty layout in the GUI
              if(newName.length() > 10)
                   JOptionPane.showMessageDialog(null,"You may not enter a name longer than 10 characters. Please try again.","Error",JOptionPane.ERROR_MESSAGE);
                   validNewEntry = false;
                   createNew();
                   return;
              //Get the new contacts surname
              String newSurname = JOptionPane.showInputDialog(null,"Please enter the new contacts surname or press cancel to exit.");
              if(newSurname == null)
                   finish();
              //If the surname is greater than 10 chars long
              //Retry and warn as this will lead to a faulty layout in the GUI
              if(newSurname.length() > 10)
                   JOptionPane.showMessageDialog(null,"You may not enter a surname longer than 10 characters. Please try again.","Error",JOptionPane.ERROR_MESSAGE);
                   validNewEntry = false;
                   createNew();
                   return;
              //If there was no surname entered check and make sure that they want a whitespace value for the surname.
              if(newSurname.length() <= 0)
                   int answer =JOptionPane.showConfirmDialog(null,"Are you sure you wish to leave the surname blank for new contact?","No date entered",JOptionPane.YES_NO_OPTION);
                   if(answer == JOptionPane.NO_OPTION)
                        validNewEntry = false;
                        createNew();
                        return;
                   else
                        validNewEntry = true;
              //Get the new contacts home number if there is one
              String newHome = JOptionPane.showInputDialog(null,"Please enter the contacts home number or press cancel to exit.");
              if(newHome.length()> 0)
                   try
                        homeNum = Integer.parseInt(newHome);
                   catch(Exception e)
                        JOptionPane.showMessageDialog(null,"You may only use numbers for a valid phone number. Please try again","Error",JOptionPane.ERROR_MESSAGE);
                        validNewEntry = false;
                        createNew();
                        return;
              // If there is a new pone number make sure that it is not longer than 10 characters
              // This may be changed as this is only correct in South Africa where phone number are not longer than 10 characters
              // If Data is changed please ensure to increase the spacing int the Layout
              if(newHome.trim().length()> 10)
                   JOptionPane.showMessageDialog(null,"You may not enter a number longer than 10 digits long. Please try again.","Error",JOptionPane.ERROR_MESSAGE);
                   validNewEntry = false;
                   createNew();
                   return;
              // Get the new work number if there is one.
              String newWork = JOptionPane.showInputDialog(null,"Please enter the contacts work number or press cancel to exit.");
              if(newWork.length()> 0)
                   try
                        workNum = Integer.parseInt(newWork);
                   catch(Exception e)
                        JOptionPane.showMessageDialog(null,"You may only use numbers for a valid phone number. Please try again","Error",JOptionPane.ERROR_MESSAGE);
                        validNewEntry = false;
                        createNew();
                        return;
              // If there is a new pone number make sure that it is not longer than 10 characters
              // This may be changed as this is only correct in South Africa where phone number are not longer than 10 characters
              // If Data is changed please ensure to increase the spacing int the Layout
              if(newWork.trim().length()> 10)
                   JOptionPane.showMessageDialog(null,"You may not enter a number longer than 10 digits long. Please try again.","Error",JOptionPane.ERROR_MESSAGE);
                   validNewEntry = false;
                   createNew();
                   return;
              // Get new cell number if there is one
              String newCell = JOptionPane.showInputDialog(null,"Please enter the contacts cell number or press cancel to exit.");
              if(newCell.length()> 0)
                   try
                        cellNum = Integer.parseInt(newCell);
                   catch(Exception e)
                        JOptionPane.showMessageDialog(null,"You may only use numbers for a valid phone number. Please try again","Error",JOptionPane.ERROR_MESSAGE);
                        validNewEntry = false;
                        createNew();
                        return;
              // If there is a new pone number make sure that it is not longer than 10 characters
              // This may be changed as this is only correct in South Africa where phone number are not longer than 10 characters
              // If Data is changed please ensure to increase the spacing in the Layout
              if(newCell.trim().length()> 10)
                   JOptionPane.showMessageDialog(null,"You may not enter a number longer than 10 digits long. Please try again.","Error",JOptionPane.ERROR_MESSAGE);
                   validNewEntry = false;
                   createNew();
                   return;
              // Check to see if contact is not a duplicate
              for(Person c: phoneList)
                   c = phoneList.get(count);
                   if((c.name).equals(newName.trim().toUpperCase())&&(c.surname).equals(newSurname.trim().toUpperCase()))
                        JOptionPane.showMessageDialog(null,"You may not enter duplicate contacts. \nPlease abbreviate or change the contacts name/surname.","Error",JOptionPane.ERROR_MESSAGE);
                        validNewEntry = false;
                        createNew();
                        break;
                   count ++;
              // If there were no phone numbers at all then set boolean to false as no point in adding a entry without numbers to a phonebook
              if((newHome.length()<=0) && (newWork.length()<=0) && (newCell.length()<=0))
                   JOptionPane.showMessageDialog(null,"You have not entered any phone numbers for "+newName+" "+newSurname+"\nThis phonebook only accepts new entries with at least one phone number.\nPlease try again!","Error",JOptionPane.ERROR_MESSAGE);
                   validNewEntry = false;
                   createNew();
                   return;
              //If all data entered was valid then try add it to the ArrayList
              if(validNewEntry == true)
                   try
                        p.name = newName.trim().toUpperCase();
                        p.surname = newSurname.trim().toUpperCase();
                        p.home = newHome.trim();
                        p.work = newWork.trim();
                        p.cell = newCell.trim();
                        phoneList.add(p);
                   catch(Exception e)
                        JOptionPane.showMessageDialog(null,"Could not add contact. If problem persists Please call the system Administrator.","Information Message",JOptionPane.INFORMATION_MESSAGE);
              list = phoneList;
         } // end of createNew()and lastly my getList() that returns the list to the GUI
    public ArrayList<Person> getList()
              ArrayList<Person> modifiedList = new ArrayList<Person>();
              modifiedList = list;
              return modifiedList;
         }Like I said it works if I do this....
    public ArrayList<Person> getList()
              ArrayList<Person> modifiedList = new ArrayList<Person>();
              modifiedList = phoneList;
              return modifiedList;
         }

    I haven't read everything yet, but looking at that code at the bottom:
    public ArrayList<Person> getList()
              ArrayList<Person> modifiedList = new ArrayList<Person>();
              modifiedList = phoneList;
              return modifiedList;
         }That first line in the method where you create a new ArrayList<Person>() doesn't do anything, since you just point modifiedList to phoneList in the next line anyways. This would do the same thing:
    public ArrayList<Person> getList() {
        ArrayList<Person> modifiedList = phoneList;
        return modifiedList;
    }Or, looking more closely at what you're doing:
    public ArrayList<Person> getList() {
        return phoneList;
    }

  • Airdrop should work, but it doesn't!

    I have a Macbook Pro, an iPhone6, and an iPad mini. All are new enough and have the latest software. The two iOS devices recognize each other, but neither of them can see the Macbook Pro, nor can it see them. All are on the same wireless network. I have the AirDrop folder open on the Mac, the iPhone and iMac are awake, and nothing.
    Could this have something to do with initial setup when I installed Yosemite? Is there some way to re-initiate it?

    Thank you for taking the time mate ;)
    This is he code changed with your code.
    when the title,first &last name is null it still only runs the 1st JOptionPanel and dosn't pass to the 2nd ??
    here is the code
      void NewShoeOrderjButton_actionPerformed(ActionEvent e) {
        String check=null;
        if(TitleComboBox.getSelectedItem() != null &&
           FirstNameJText.getText() != null &&
           LastNameJText.getText() != null)
          check=TitleComboBox.getSelectedItem()+FirstNameJText.getText()+LastNameJText.getText(); //the rest of the thing.......;
    //then you check "check":
        if(check != null){
          //show the first optionpane
          String[] options = {"Yes", "Cancel"};
          String d= System.getProperty("line.separator");
          int result = JOptionPane.showOptionDialog(null,
              "Do you really want to add a new shoe order for:"+ d +
              (String) TitleComboBox.getSelectedItem()+" "+FirstNameJText.getText()+
              " "+LastNameJText.getText(),"New Order",
              JOptionPane.YES_OPTION,
              JOptionPane.INFORMATION_MESSAGE,
              null,
              options,
              options[0]);
          switch(result){
            case JOptionPane.YES_OPTION: // Add your code for no
              setFieldsEditable(false);
              break;
            case JOptionPane.NO_OPTION: // Add your code for yes
              // just playing with button
              setFieldsEditable(true);
              break;
        }else{
          //show the second optionpane
          JOptionPane.showMessageDialog( null,
                                         "There is no order", "No Order",
                                         JOptionPane.WARNING_MESSAGE);
      }

  • HT1495 My husband and I share an i cloud account but each have our own separate ipads. We were told this would work, but now I can't find a book that I've downloaded on my ipad anymore. Where would I find it?

    My husband and I share an i cloud account but each have our own separate ipads. We were told this would work, but now I can't find a book that I've downloaded on my ipad anymore. Where would I find it?

    You and your husband can share a store account and still have seperate iCloud accounts for your contacts, bookmarks and stuff like that.  Click here for instructions to make an apple account without entering a credit card.  Make sure you use a different email address for each apple account. 
    Set up your iPhone/iPad whatever using the new account for iCloud.  Then go into settings/store and sign in with your purchasing account, you may need to sign out of the other account.  To the best of my knowledge, your household is allowed to share purchased legally, someone please correct me if I'm wrong.
    Once you each have your own devices set to your own accounts you can set them to backup to that account and it will keep all your contacts seperate.

  • When my iPhone is connected (via the Lightning cable) to the usb port in my car, the alert tones are no longer played through the car speaker or the phone.  This previously worked, but has randomly stopped working, help!

    When my iPhone is connected (via the Lightning cable) to the usb port in my car, the alert tones are no longer played through the car speaker or the phone.  This previously worked, but has randomly stopped working. help!

    I took my iPhone to the Service center of M/s RSG INFOTECH PRIVATE LIMITED on April 17, 2014.
    Why are you posting in this forum about what occured with an independent service provider?  How is is at all relevant to Apple??  In fact, service by any person or business not authorized by Apple voids any waranty.

  • Fan noise/overheating issue? I have a late 2008, 15'' MBP and I'm having a lot of fan noise while just running safari. I don't think this is normal but perhaps it is? Thanks for any and all help!

    Fan noise/overheating issue? I have a late 2008, 15'' MBP and I'm having a lot of fan noise while just running safari. I don't think this is normal but perhaps it is? Thanks for any and all help!

    Runaway applications can increase fan activity

  • What HDMI cable do I need for my MacBook (2009) to my SONY HDTV? I thought the HDMI cable from my Apple TV would work, but it doesn't.

    What HDMI cable do I need for my MacBook (2009) to my SONY HDTV? I thought the HDMI cable from my Apple TV would work, but it doesn't.

    The model 7,1 is actually the Mid 2010 MacBook and is the only MacBook with a Mini DisplayPort that sends audio along with the video, Here's some Mini DisplayPort to HDMI with audio adapters from Amazon.
    http://www.amazon.com/s/ref=nb_sb_ss_i_3_35?url=search-alias%3Daps&field-keyword s=mini+displayport+to+hdmi+with+audio+for+macbook+pro&sprefix=mini+displayport+t o+hdmi+with+audio%2Caps%2C252

  • Keep getting error message "The registry settings used by the iTunes drivers for importing and burning CDs ....please reinstall iTunes." I have done this several times but it doesn't help.

    Keep getting error message "The registry settings used by the iTunes drivers for importing and burning CDs ....please reinstall iTunes." I have done this several times but it doesn't help.

    Refer to this article:
    iTunes for Windows: "Registry settings" warning when opening iTunes
    http://support.apple.com/kb/TS3299

  • Handling event in subVI

    Hi all,
    I register an event (value change for a boolean array) in a subVI.  I connect the refnum with the dynamic event connector (event loop) the in the higher level VI.  So the loop will fire when the subVI's boolean array change.
    It works well only if the front panel's subVI is opened.  I don't want the subVI running with the front panel opened.  Someone can help me to figure out what should be done?
    Thanks.
    Solved!
    Go to Solution.

    This is the expected behavior. I would recommend that instead of using the value change event create your own user event. Then have your subVI trigger this event when it modifies the array. The event structure in the calling VI will receive your user event and take the appropriate action. Relying on a value change event is not the best way to do these types of things. Also, using a user event helps to decouple the UI from the processing tasks. This is a good preferred design because it is more flexible and easier to change one side or the other. As long as the event data is consist you are free to change either implementation.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • You guys think this will work?

    Im just wondering if you guys think that this will work on intels.
    http://www.resexcellence.com/news/?p=127

    You need Boot Camp and Windows installed as the ATI utility is .exe (make sure it's the latest .25 version)
    http://www.techpowerup.com/downloads/Tweaking/ATITool
    Tales of the brave/foolhardy souls who've tried it:
    http://forum.onmac.net/showthread.php?s=77142640a51e9bc7608af0bd7dba7bf3&t=767
    Heat is already an issue, this isn't going to help any IMHO

  • This should work

    I just purchased a Maxtor 200 GB and an enclosure. I had another enclosure with a 120 GB. Both are Oxford chips. Both are 400 firewire.
    I had the 120 setup as a bootable backup, and have no trouble with that working as it should. It shows up in Startup Manager, and can be selected and used as a stratup device.
    Now, the 200 is another issue. I clone over a copy of my hard drive, and it does not show up in Startup Manager. It shows up in the Startup Disk Pane, but when I select it, it goes to the internal drive.
    I switched enclosure cases, and the 120 still works, but the 200 still does not.
    1. Repaired the 200 disk with DU and DW (no problems found).
    2. Reset PRAM
    3. Reset PRAM again
    4. As I said, I switched the enclosures
    Anyone got a helpful hint? Thanks.

    Done it many times myself. Here's how to hide those files:
    Here's how to make a /.hidden file. This only works for admin users.
    1. Open the Terminal.
    2. Type "pico /.hidden" without the quotation marks.
    3. Type the names of the file/folder you want hidden.
       The resulting list should have one name per line.
    4. Hit Control-O then the Return key to save /.hidden.
    5. Hit Control-X to Exit.
    6. Type "sudo chmod a=r /.hidden" without quotes.
    7. Enter password if asked.
    8. Type "sudo chown root:wheel /.hidden" without quotes.
    9. Quit Terminal.
    10. Restart the Computer.

  • It Should work, but it won't

    Sent from Cisco Technical Support iPad App
    We have a new install of OM3 fiber between buildings. Distance is around 600 FT. One one end is a 4510RE running cat4500e-UniversalK9-M, ver 03.02.00.SG (fc4). Connecting to line card WS-X4306-GB with a WS-5486-LX/LH GBIC in port 3.
    On the other end, and 3750-24-PS switch with a GLC-LH-SM= module. Code on the 3750 is: c3750-ipbasek9-mz.122-55.SE4
    The fiber is tested good. Notice the GLC-SM-LH is showing at and LX module in the 3750 show inventory. Have replaced module with know working modules and tested module on know working links. All tests are positive. Does not appear to be configuration issues on the interfaces.
    Any thoughts on what to do next. Compatibility matrix says this should be good. Are my modules not good for OM3, even though Cisco says they are?

    Hi,
    You are trying run single mode gbics accross a multimode OM3 50/125 fibre.
    You will need to deploy conditioning fibre patchcords to offset the the single mode signal.
    http://www.cisco.com/en/US/prod/collateral/modules/ps5455/product_bulletin_c25-530836.html
    Regards,
    Alex.
    Please rate useful posts.

Maybe you are looking for

  • PI 7.1 can't FTP XML to XML.

    hi All, currently i was trying to configure the PI for very simple CASE like how to FTP file XML to XML follow the guide below http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/00a4c567-f5f8-2b10-02af-c9e9033591ae?QuickLink=index&ove

  • Remote Desktop connection - Set URL by group policy

    on our 2008 R2 DC we do not have a "RemoteApp and Desktop Connections" entry and so i cant set the Default URL of the RDS web , how i can have an admx for this policy or any work around in order to set the URL by group policy, by the way i have an rd

  • Control Flash8 swf movie in Flex 2

    I have a swf (output from OpenOffice, created from a PowerPoint presentation) and i want to control it from Flex 2 (i don't have the .fla file of the swf). Is this possible at all? I can load the swf and display it, but no way of accessing it as a Mo

  • Data paging with Flex and ASP Vb

    Can some help me with the (asp) code to get this working? With Regards, Dik

  • Subcontracting material issue

    Hi i got some process error i have created a SC PO aganist which i have to issue material to vendor is 100 but i have issued 50 pc of component again when i do goods issue aganist PO system is showing 100 pc instead of 50 and this issue 541 against P