AS 3 Convert button event to key enter event

I'm learning how to use regular expressions in ActionScript
3, and can get an input to be tested by regular expressions, and an
answer delivered, if a button is clicked after text is entered.
But darn if I can figure how to code it so they just click
the enter key after typing what they like. In the following code
punk is a button, and there are two text fields, buzzo the input,
and tester the answer to the input. The array questo contains the
regular expressions, the array anso contains the responses.
I need code to replace the bottom line with a line that
relates to key enter being typed. Thanks for any ideas.
Sally

This will work if the code is on the timeline:
var quest0:RegExp = /i was/i
var quest1:RegExp =/\bbud(dy)?|mate/i
var quest2:RegExp =/how old|\bage\b/i
for(i=0;i<3;i++){
questo.push(this["quest"+i])
trace(questo[1])
Another method might be to add your RegExp objects to a
Object, and then
iterate the Object's properties and add the RegExp objects to
your array:
import flash.utils.getQualifiedClassName;
var RegExpContainer:Object = new Object();
RegExpContainer.quest0:RegExp = /i was/i;
RegExpContainer.quest1:RegExp =/\bbud(dy)?|mate/i;
RegExpContainer.quest2:RegExp =/how old|\bage\b/i;
for(var p in RegExpContainer){
var o = RegExpContainer[p];
if (getQualifiedClassName(o) == "RegExp"){
questo.push(o);

Similar Messages

  • Get Buttons to respond to ENTER key

    What's the best way to get a button to respond to the ENTER
    key (when the given button has focus)?
    As of now I'm checking the ID of object that has focus (in
    the main application), and it seems to work fine, as below:
    private function goKey(event:KeyboardEvent):void {
    . if (event.keyCode == Keyboard.ENTER) {
    . . var iF:Object = getFocus();
    . . if (iF.id == "myButton") {
    . . . // execute code here
    ... but I'm wondering if there's a more elegant way to do it,
    which will open up my understanding of Flex.
    thanks.

    There are probably lots of ways to handle this. I typically
    add my keydown
    handler on the container that holds the buttons
    then in the event handler look at the event.target. It its a
    button then
    dispatch a mouse click event. Then the click event handler
    for the button
    will be called as if the user clicked it with a mouse.
    just do this:
    private function handleKeyDown(event:KeyboardEvent):void
    var char:uint = event.keyCode;
    var enterChar:uint = 13;
    var tabChar:uint = 9;
    var pgUp:uint = 33;
    var pgDown:uint = 34;
    if(char == enterChar)
    if(event.target is Button)
    var bt:Button = event.target as Button;
    if(bt.enabled == false)
    return;
    var c:MouseEvent = new MouseEvent(MouseEvent.CLICK,true);
    bt.dispatchEvent(c);
    return;
    }

  • How to detect the key enter with a numerical control without using loop event?

    I want to accept a numerical value only when the key enter is pressed, but without using the event. How to detect the char "enter" with a numerical control?
    Thanks!

    When the user edits a numeric control with a keyboard, its property "key focus" is true. When the user hits enter, key focus becomes false. Poll the property to latch the control valuse at the true-false transition. That won't work if the user modify the control using up and down arrows.
    LabVIEW, C'est LabVIEW

  • InputListofValue PopUp window CANCEL button event capture ?

    HI All ,
    Jdeveloper version 11.X.6.
    i have explained the outline of issue below:
    User enter some data on InpuLIstOfValue text field and click on the maginfied Glass, the pop opens and selects some data and click 'OK' ,it will display appropriately on below fields.
    but if user enters the wrong data on InpuLIstOfValue text field and clicks on maginfier Glass,no results found on the popup window, so upon click of "CANCEL" button on popup window ,
    is there any way to remove the old data on InpuLIstOfValue Filed ?
    Basicaly i am looking for the capturing the CANCEL button event on the popUpwindow ,based on event status .
    PLase let us know if any hints ?
    Thanks

    Step by step:
    1. Create the converter class:
    package view.converters;
    import java.util.Collection;
    import java.util.Collections;
    import javax.faces.component.UIComponent;
    import javax.faces.context.FacesContext;
    import javax.faces.convert.Converter;
    import org.apache.myfaces.trinidad.convert.ClientConverter;
    import org.apache.commons.lang.StringUtils;
    public class LOVConverter implements Converter, ClientConverter {
      public Object getAsObject(FacesContext facesContext, UIComponent uiComponent, String value) {
        if (StringUtils.isBlank(value)) {
          // cancel event was triggered, so do something
        return value; // if value is not an instance of String you need to convert it to its primary type (Number, Date, String, etc)
      public String getAsString(FacesContext facesContext, UIComponent uiComponent, Object value)
        if (value == null || /* value is empty in its primary type */) {
          // cancel event was triggered, so do something
        return value.toString();
      public String getClientLibrarySource(FacesContext facesContext)
        return null;
      public Collection<String> getClientImportNames()
        return Collections.emptySet();
      public String getClientScript(FacesContext facesContext, UIComponent uiComponent)
        return null;
      public String getClientConversion(FacesContext facesContext, UIComponent uiComponent)
        return null;
    }2. Declare the converter in faces-config.xml:
    <converter>
      <converter-id>LOVConverter</converter-id>
      <converter-class>view.converters.LOVConverter</converter-class>
    </converter>3. Your inputListOfValues should look like this (see the property converter="LOVConverter"):
    <af:inputListOfValues popupTitle="Search"
                          value="#{row.bindings.DepartmentId.inputValue}"
                          model="#{row.bindings.DepartmentId.listOfValuesModel}"
                          required="#{bindings.EmployeesView1.hints.DepartmentId.mandatory}"
                          columns="#{bindings.EmployeesView1.hints.DepartmentId.displayWidth}"
                          shortDesc="#{bindings.EmployeesView1.hints.DepartmentId.tooltip}"
                          converter="LOVConverter"
                          id="ilov1">After that, when the user clicks the Cancel button, both methods (getAsObject and getAsString) should be invoked, and then you would be able to reset the component value (using uiComponent parameter).
    AP

  • All web pages appear with a blinking cursor like in a "word document". i can't scroll down or up using the buttons of my key board. i have to pull down the scroll bar. something in settings has changed. how to correct it??

    all web pages appear with a blinking cursor like in a "word document". i can't scroll down or up using the buttons of my key board. i have to pull down the scroll bar. something in settings has changed. how to correct it??
    == This happened ==
    Just once or twice
    == 2 days ago.

    See also this article about caret browsing: http://kb.mozillazine.org/Scrolling_with_arrow_keys_no_longer_works
    In Firefox 3.6 and later versions you can disable the F7 shortcut that toggles caret browsing by setting the pref accessibility.browsewithcaret_shortcut.enabled to false.
    To open the ''about:config'' page, type '''about:config''' in the location (address) bar and press the Enter key, just like you type the url of a website to open a website.
    If you see a warning then you can confirm that you want to access that page.

  • How to make 'Key-Enter' trigger (when clicked on enter key)work like 'F8' key?

    Hi . I have another question to be asked.
    Oracle Forms 6i.
    I have a form in which DEFAULT&SMARTBAR is the menu and there are no push buttons.
    In the form, there is a 'field' named as 'ID No'. After entering 'ID No' in the field and click on 'Execute Query' button from the 'DEFAULT&SMARTBAR' menu, all the details of that respective 'ID No' gets displayed in all the other fields. Even if i press 'F8' all the fields gets displayed with the values.
    But i have a requirement, i.e. after entering 'ID No' and click 'Enter' key , i want all the values to be displayed.
    So i created a 'Key-Enter' trigger with the following code:
    BEGIN
      EXECUTE_QUERY;
    END;
    But after entering 'ID No' and click 'Enter' key, the values are not getting displayed.
    What can i do to make this happen?
    Thank You.

    It depends how your form is created. If your ID item is part of the base table block, you can do this.
    On your ID item, create a KEY-NEXT-ITEM trigger:
    if :system.mode = 'ENTER-QUERY' then
        execute_query;
    else
        next_item;
    end if;
    Now
    - User clicks on enter query (via smart bar icon or F7).
    - User enters ID and clicks <enter> key to execute the query.

  • Execute procedure in pl/sql button event handler

    i have a demo application which consists of text boxes
    eg : when i enter department no in first text box and click proc
    it should display dname and loc in the below text boxes.
    my proc is working fine in sql*plus but its showing errors in pl/sql button event handler.
    any ideas
    my proc is create or replace procedure proc1 (no number)
    as
    DNAME1 dept.dname%type;
    LOC1 dept.loc%type;
    begin
    select DNAME,LOC into DNAME1,LOC1 from scott.dept where deptno = no;
    DBMS_OUTPUT.PUT_LINE (DNAME1);
    DBMS_OUTPUT.PUT_LINE (LOC1);
         Exception When No_Data_Found then
    dbms_output.put_line('Entred name is not found');
    When Others then
    Null;
    End;
    /

    Hi,
    you have to use
    htp.p('<SCRIPT LANGUAGE="Javascript1.1">
    document.all("FORMNAME.DEFAULT.ATTRIBUTENAME.01").value="'||DNAME1||'";
    document.all("FORMNAME.DEFAULT.ATTRIBUTENAME.01").value="'||LOC1||'";
    </SCRIPT>
    instead of
    DBMS_OUTPUT.PUT_LINE (DNAME1);
    DBMS_OUTPUT.PUT_LINE (LOC1);
    where formname is your form name and attribute name is the field name on the page.

  • Handling Button Event

    Hi all,
    i am using a 'When-Validate-item' trigger in this i am doing a validation,
    when user try to enter amount greater than the given amount(This is needed validation)
    and also i am regenerating new lines(Creating new records when button pressed)
    when i am regenerating i should not validate.
    How to handle button event
    Thnx
    Raj

    Hi...
    The WHEN-VALIDATE-ITEM Trigger fires once you updated a field. Be sure you raise
    form_trigger_failure when amount is invalid. So, the cursor stays in field amount. You cant
    leave this field until the amount is not valid.

  • ExportPDF Convert button grayed out

    Two days ago my company paid for a subscription to ExportPDF. But when I open a document in Acrobat 11.0.06 and sign in, the Convert To: option button and the Convert button are grayed out. Nothing works, no error messages, no indication of any problem. The product indicates that we paid for 12 months of unlimited conversions of PDF to Word, Excel, and maybe RTF, but so far this has been a waste. Three different useless chat sessions finally brought me here. Does anyone know anything useful to try?

    David,
    Thanks much for your reply! But unfortunately that is not the reason because as I noted above " ... when I open a document in Acrobat 11.0.06 and sign in, the Convert To: option button and the Convert button are grayed out."
    I have also tried to use ExportPDF from the web tool, same result.
    Here is what happens.
    I open any PDF I'd like to convert. In the Tools panel on the right, I toggle open ExportPDF. At this point, the Convert To: and Convert buttons are available. If I click either one, I get the notice that this requires a Paid Account and to Sign Up Now. Since I have already paid, I close that and go to the little blue Sign In link at the upper right corner.
    A Sign In box pops up asking for my password as my Adobe ID email address is now prepopulated. I enter my password and get logged in as indicated by the username at the upper right.
    BUT the Convert To: and Convert buttons in the ExportPDF panel are still grayed out and now there is the light blue box that indicates this requires a Paid Account and I need to Sign Up Now. So you see this is an endless loop to nowhere. (Same thing happens on the web, constantly prompted to pay, even though I already have.)
    My guess is that the system has failed to register that I am a paid user. Can you unstick this and make it work correctly?
    It's now been about a week since we paid, the option does not work, and I believe this is something simple. I need to be able to use this as Adobe advertises or request a refund.
    Thanks,
    Charlie

  • Handling button events in large app

    I'm currently examining a large swing app, and have observed the following with regard to action events.
    A number of listeners (for buttons, menu items, JLists etc.) are defined at the top of the app. These variously extend MouseAdapter or implement ActionListener, depending on the type of component whose actions they listen for.
    The ButtonListener definition is as follows :
    private class ButtonListener implements ActionListener
    public void actionPerformed(ActionEvent event)
    Object object = event.getSource();
    if (object == button1)
    // button1 actions
    else
    if (object == button2)
    // button2 actions
    .....etc
    One instance of this listener is created in the app, and is used as the actionlistener for each button. This means that the buttonlistener is quite large (as it contains the code for each button in the app).
    Is this the proper way to handle button events for an app with a large number of buttons?

    Thanks for the responses.
    In response to theDude : I agree that defining the action listener for each button can be useful when you can see the button definition and button action in one place; one could counter that by saying that grouping all the button actions makes it easier to examine all button actions in one place.
    Setting the action command isn't really an option because the application creates panels of buttons on the fly, e.g. when notification of a new customer is received, a new panel is created with a JTextPane (customer description) and a row of buttons for "Modify", "Delete" and "Print".
    Several customer panels could be in existence at the same time, so setting an action command of "Modify" would not enable one to uniquely identify which "Modify" button was pressed.
    This problem is currently handled by associating the panel instance with a "Customer" class instance in a hashtable. The "Customer" class consists of a JTextPane field, and a JButton for each function. When a button is pressed, the button listener traverses up the component's parents until it reaches the panel (i.e. it loops until the parent is a key on the hashtable, at which point it can retrieve the Customer instance and check which button was pressed).
    In response to KPSeal : If I understand you, I would define "ApplicationAction" separately from the main app and define extensions of it in the main app for each type of action. Would this add much value over merely defining a method for each type of action in the main app and just calling this method when the relevant button/menu item was pressed/selected?
    There doesn't seem to be a universal approach to event handling, but I thought there might have been one accepted strategy when an app has large numbers of buttons (some created on the fly, ruling out action commands).

  • Short cut for Radio buttons (using Ctrl+ key)

    How can I select deselect Radio buttons using Ctrl + keys. I know that setMnemonic can be used to access using Alt + key. But I want to use Ctrl also. Please suggest the solution. How can I select using only single key?

    Read the API for a meaning of each of the arguments. Here is a simple example showing how to assign an "Action" to the Ctrl+1 and Ctrl+2 keys:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class KeyboardAction extends JFrame
        public KeyboardAction()
            JPanel panel = new JPanel();
            setContentPane( panel );
            JTextField textField1 = new JTextField("Ctrl+1 or Ctrl+2", 10);
            panel.add( textField1 );
            JTextField textField2 = new JTextField("Ctrl+2", 10);
            panel.add( textField2 );
            //  Change the input map of the text field,
            //  therefore, Ctrl+1 only works for the first text field
            Action action1 = new SimpleAction("1");
            Object key1 = action1.getValue(Action.NAME);
            KeyStroke ks1 = KeyStroke.getKeyStroke(KeyEvent.VK_1, KeyEvent.CTRL_MASK);
            textField1.getInputMap().put(ks1, key1);
            textField1.getActionMap().put(key1, action1);
            //  Change the input map of the panel
            //  therefore, Ctrl+2 works for both text fields added to the panel
            Action action2 = new SimpleAction("2");
            Object key2 = action2.getValue(Action.NAME);
            KeyStroke ks2 = KeyStroke.getKeyStroke(KeyEvent.VK_2, KeyEvent.CTRL_MASK);
            panel.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(ks2, key2);
            panel.getActionMap().put(key2, action2);
        class SimpleAction extends AbstractAction
            public SimpleAction(String name)
                putValue( Action.NAME, "Action " + name );
            public void actionPerformed(ActionEvent e)
                System.out.println( getValue( Action.NAME ) );
        public static void main(String[] args)
            KeyboardAction frame = new KeyboardAction();
            frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
            frame.pack();
            frame.setVisible(true);
    }Also, if you search the forum using the keyword "getActionMap", I'm sure you'll find other example.

  • Loading Flash Paper swf causes all other button events to fail

    Hi Everyone,
    I have created a project with Flash which I am using Zinc to publish as a projector for both Macs and Pcs. Now, in this app I am loading a pdf document converted to a Flash Paper swf. The moment I load this swf file into my project, it appears as though all other button events fail. If I remove the code which loads in the flash paper swf, all buttons function as expected.
    Can anyone please help me with a reason / solution for this?
    Any help is greatly appreciated!
    Cheers!

    Did that and there were no errors shown at any point, such as when publishing the .apk file.
    I found a solution. I was under the impression I needed to use touch events for it to work on a tablet, and changing those to normal mouse events solved the problem. Still not sure why it wouldn't work the other way, but for now it works as needed.
    Thanks!

  • Key-ENTER

    Dear all,
    I have a question on Key-ENTER event.
    If I want to fire a function after user enters some text on Text Item and Press the "ENTER/RETURN" key, which trigger event that I should put the code in?
    Dummy

    You should write your code in the Key-enter trigger. It would also help if you write the following code in the key-next-item trigger of the item:
    do_key('ENTER');
    null

  • How can a new button Event open sales order

    CRM WEB UI issue.
    On assignment Block there is a New button , on New button Event i have to open sales order .
    Please help me.
    Thanks in advance .
    Kumar6

    Hi Kumar,
    Whenever you got any requirement then find out on Web UI how they have done it. As now you want to show sales order then first find out Component name for Sales order.
    So Go to transaction u2018CRM_UIu2019. Chose u2018SalesProu2019 as a Role.  In Navigation Bar click on u2018Sales Cycleu2019  and in Second level link there is u2018Sales Orderu2019. Click on it. Check  it is a screen you want on your button click.
    If yes then you need to find its Technical Data (details). So click inside Work Area and press u2018F2u2019 key.
    Then you will get UI component name, View name , Context name, Role key, etc. So you have to pick that UI Component name and give it in Transaction Code  u2018CMP_WD_BSPWBu2019.
    Now Go To  u2018Run Time Repositoryu2019 , In Component Interface They have created u2018Component Interfaceu2019 that you need to call in your Button click event. If you donu2019t know use of u2018Component Interfaceu2019 then first read it else its good for you.
    Well next time when you will write any Question, In Subject write it in One line so that all can see in list and answer you quickly.
    Thanks,
    Durgesh Pagar.

  • To click submit button when I press Enter

    I want to activate my SUBMIT link(not button) when I press the "ENTER" button in my Key board. I am using Struts.
    Message was edited by:
    ashish.0532
    Message was edited by:
    ashish.0532

    You have to use javascript to do this. Most browsers only support default buttons, not links.

Maybe you are looking for