TextField keeps focus

Hi,
I have the following problem:
On my stage sits a MC: personTab.nameBase. Inside the
nameBase clip there are 10 input fields named input## (numbered
from 0 - 9).
When I click one of these fields the cursor starts blinking
in the field which is clicked. This is OK, but the problem is that
the field doesn't loose focus unless a component is clicked
(radiobutton, combobox etc.).
I put in a listener to trace what happens:
In the onSetFocus event I get the target of the clicked field
and when I click the mouse somewhere on stage (where no component
is placed I get null as a target, but when I release the
mousebutton, the last selected field receives focus again and the
target of the field is returned again (instead of null). The
onKillFocus event doesn't return a thing. I already tried handling
the focus in the onSetFocus event in the following manner:
var clip:Array = newFocus._name.split(".");
if (substring(newFocus._name, 1, 5) == "input") {
var clipID:String = substring(newFocus._name, 6,
newFocus._name.length);
_global.activeField = clipID;
} else {
if(!newFocus._name){
//remove focus from textFields
Selection.setFocus(null);
delete _global.activeField;
But there is no response to Selecion.setFocus(null), the last
selected input field keeps getting focus after the mouse is clicked
on somewhere else on stage (but not on a component, or other text
field).
I hope someone can help me out. Thanks in advance.
Best regards,
Rick.

onRollOver (your button) you store the begin and end index of
the Selection (in the textfield), onRelease(of your button) you set
your red textFormat on the previously stored indices, then you set
Selection.setSelection back to what it was...

Similar Messages

  • Keep focus in a control until certain conditions are met?

    Hello,
    Is there a way to keep focus at a control until certain conditions are met?
    For example, if I might want to keep the focus set to a text field inside a tab unless the text field contains something valid.
    If user tries to switch to different tab without having valid text inside the text field, I would like to pop up a stage/dialog and abort the tab switching.
    Please help!
    Thanks.

    Hi. Here is an example:
    import javafx.application.Application;
    import javafx.beans.value.ChangeListener;
    import javafx.beans.value.ObservableValue;
    import javafx.event.ActionEvent;
    import javafx.event.EventHandler;
    import javafx.scene.Scene;
    import javafx.scene.control.*;
    import javafx.scene.layout.*;
    import javafx.scene.paint.Color;
    import javafx.stage.Modality;
    import javafx.stage.Stage;
    import javafx.stage.StageStyle;
    import javafx.stage.WindowEvent;
    public class SSNValidation extends Application {
        public static void main(String[] args) {
            launch(args);
        @Override
        public void start(final Stage primaryStage) {
            primaryStage.setTitle("SSN Validation");
            Button btn = new Button();
            final TextField tfSSN = new TextField();
            StackPane layout = new StackPane();
            Scene scenePopup = new Scene(layout, 424, 154, Color.TRANSPARENT);
            final Stage stage = new Stage();
            stage.initModality(Modality.APPLICATION_MODAL);
            stage.setScene(scenePopup);
            stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
                @Override
                public void handle(WindowEvent event) {
                    tfSSN.requestFocus();
            tfSSN.focusedProperty().addListener(new ChangeListener<Boolean>() {
                public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, final Boolean newValue) {
                    if (!newValue) {
                        if (tfSSN.getText().length() < 9) {
                            stage.show();
            final TextField tf2 = new TextField();
            btn.setText("Submit");
            VBox root = new VBox();
            root.getChildren().addAll(tfSSN, tf2, btn);
            primaryStage.setScene(new Scene(root, 300, 250));
            primaryStage.show();
    }

  • JFrame not keeping focus

    How can I ensure that a JFrame will always keep focus?. I need it to always remain on top and be visible
    thanks

    A tricky one.
    Java doesn't allow this. Not even the upcoming version 1.4 allows this.
    I have done it, though and many people on this forum have. What you need to do is go native. If you are on the Windows platform write a JNI (Java Native Interface) compliant DLL and call it from your code using the native keyword. If you want some code write me at [email protected]
    Morten Hjerl-Hansen

  • IPhone 4 keeps focusing and refocusing in video

    When shooting video with my iPhone 4, the image keeps focusing and refocusing as I move the camera causing the picture to pop in and out of focus. It's happening in all video apps so I'm suspecting the phone.
    Ideas?

    Basic troubleshooting steps clearly outlined in the User Guide are restart, resest, restore from backup, restore as new.
    If you still have problems after going through ALL the recommended troubleshooting steps, then you likely have a hardware issue.  You'll need to bring your phone into Apple for evaluation.

  • Keep focus and actionlistener

    I open as a popup a custom JPanel but
    I want to keep focus and actionlistener on it
    while it is opened.
    is there a way?
    thanks for any clue

    I tried removing all the pattern validations on the field and added this below code in the validate event of the text field and it works..
    var strCode;
    var f = /^([A-Z]{2}[1-9]{5}[A-Z])$/;
    if(this.rawValue != null && String(this.rawValue) != "") {
                        strCode = String(this.rawValue);
                        if (f.test(strCode) == false) {
                                            xfa.host.messageBox("Invalid pattern!");
                                            xfa.host.resetData();
                                            xfa.host.setFocus(this);
    xfa.host.setFocus(this);

  • TextField get focus by mouse?

    public void actionPerformed(ActionEvent actionevent) {
    if ( textField.isFocusOwner()==true)
                   if(textField.getText().equals("Please input text") )
                        textField.setText("");
    }But TextField get focus by pressing "Enter key".
    How could i use mouse to get focus in TextField??
    Thanks a lot !!

    you can add a mouse listener to you frame so whenever someone clicks any of the mouse buttons it will give the text field the focus. Is that what you are looking for?

  • Activate a trigger when a textfield is focused

    Hello all,
    I have a textfield and I want to execute a procedure when that textfield is focused. I want to do this by using the keyboard and not the mouse.
    For example when I am at a textfield called X, I want to press the Tab button and move to textfield Z. Then I want my procedure to get executed.
    Which trigger do I have to use?
    Thank you

    I read the initial problem :
    "I have a textfield and I want to execute a procedure when that textfield is focused"
    and I bet, that he needs the feature too, when he enter the Item via "Next_Item", "Previous_Item", "Next_Record", "Previous_Record", "Next_Block", "Previous_Block", ...
    these are the classical problems, when navigating to an item, when the developer thinks, that the user typically goes to that item via TAB. But after the first tests he learns, that SHIFT-TAB and all the other shortcuts described above have to work too.
    At that point it's much better to use a WNII than Key-Triggers
    Gerd

  • TextField loses focus only to another TextField

    ...when any UIComponent is onstage. If a UIComponent is not onstage, I can click anything else, even the blank stage backing, and the TextField loses focus.
    I want the TextField to have a FOCUS_OUT event when the stage (or anything else) is clicked. How can this work when there are a number of UIComponents onstage? I can hack it by putting a blank text field in back of everything, but that won't work in every case. Any ideas? Thanks.

    textField2.setDocument(textField1.getDocument());Once you do this, whatever is put into one text field will show up in the other and vice versa. Not sure if this is what the OP wants, but it does solve the problem.

  • Treeview, keep focus on clicked node ?

    First post here, hope I am in the right location.
    I am using Visual Studio Express 2103 for web. On my asp page I have a Treeview with 4 Levels. From sql server I load the hierarchy as
    TopLevel-->
                      Product-->
                                       Keyword-->
        Article
    User would click on product, then view a list of all keywords, click on the keyword and then see a list of all articles with this keyword, when the article is clicked, the related information will be shown in various text boxes to the right of the tree.
    The problem I have is that when I scroll down the list on my web page, and click any nodes that are more than 1 page down, the focus (for lack of a better word) jumps to the top of the page, now I have to scroll all the way down to the node clicked.
    How can I prevent all of this scrolling and keep the focus on the last clicked node, whether it is on the first or the tenth page.
    Thank you in advance.

    Thanks, I have done this before in regular VBA but unfortunately selectednode property is read only in ASP.
    I have since posted up in the ASP.net forum here
    asp.net
    Hi Andre,
    Since you have got where to get supports for asp.net issues, I would recommend you focus on that thread to get help.
    Regards.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Keeping focus in the viewable window of a scroll pane

    I have many text fields and text areas inside a scroll pane. When I use tab to cycle through these boxes the focus goes out of the viewable window rather then the scroll pane moving to follow the focus. Is it possible for the scroll pane to follow the focus? I would think it is. But I haven't been able to figure out how. Any ideas?
    Thanks,
    Mark

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class test extends JFrame {
      FieldListener fieldListener = new FieldListener();
      final static int fieldNumber = 15;
      JPanel panel;
      public test() {
        super("Focused Scrolling");
        panel = new JPanel();
        panel.setLayout(new GridLayout(0,1));
        JTextField textField;
        for(int i = 0; i < fieldNumber; i++) {
          textField  = new JTextField("TextField # " + i);
          textField.addFocusListener(fieldListener);
          panel.add(textField);
        JScrollPane scrollPane = new JScrollPane(panel);
        getContentPane().add(scrollPane, "Center");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setSize(300,200);
        setLocation(350,200);
        setVisible(true);
      class FieldListener extends FocusAdapter {
        public void focusGained(FocusEvent e) {
          JComponent field = (JComponent)e.getSource();
          Rectangle r = field.getBounds();
          //System.out.println("r = " + r);
          // JComponent method sends message to component's
          // parent who implements scrollable interface
          panel.scrollRectToVisible(r);
      public static void main(String[] args) {
        new test();
    }

  • PDF Keeps Focus Till Closed

    Situation:
    I launch my site to a full window lacking any browser
    navigation. Let's call this window the "main window". I do this to
    control how the site is navigated. I use the javascript popup
    window code with no problems. I now need to do a link to a PDF
    document on another website, and I don't want the main window to
    close. I can easily create this link by using the getURL and
    opening the PDF in its own window (_blank). However, if a viewer
    clicks anywhere outside the PDF, then the PDF loses focus and goes
    behind my main window. They would have to know how to use the alt +
    tab to view the PDF which will NEVER happen with my viewers nor do
    I want them to have to do this.
    Code:
    on (release) {
    getURL("
    http://web03.fahc.org/xpedio/groups/public/documents/fapolicy/anes2.pdf",
    "_blank");
    Question:
    Is there a way to get the PDF to keep the focus until the
    viewer closes the PDF?
    Thanks,
    KJM

    Use setModal(true)
    Denis

  • Keep focus in the same window after opening a new window per key-event

    I have an application in which user can press on a specific key, and that opens a new window in a JFrame. User might want open a few of such windows in a row by changing the cursor position and pressing the same letter key. But the problem is that with every new window Java VM transfers the focus to that new window. User is forced either to click to regain focus, or to move the mouse out-and-in the window, in which case the focus returns to it as well, assuming the X11 style of focus by cursor position of course.
    Is there any way to keep the focus with the window on which the cursor is placed?

    In your ActionListener your code should be something like:
    JFrame anotherOne = new JFrame();
    anotherOne.setVisible(true);
    originalFrame.requestFocusInWindow();If you need further help then you need to create a [Short, Self Contained, Compilable and Executable, Example Program (SSCCE)|http://sscce.org], that demonstrates the incorrect behaviour.
    Don't forget to use the Code Formatting Tags so the posted code retains its original formatting. That is done by selecting the code and then clicking on the "Code" button above the question input area.

  • JFileChooser in Applet keeps focus after selection of a directory

    I have spent several days on the following issue, but haven't found any solution so far...
    When I open a JFileChooser out of an Applet and select a Directory, the FileChooser closes as expected, but a text field located on the main applet pane cannot be selected any more (the mouse pointer goes to "text cursor" style when hovering over it, but the text field does not get the focus when clicked). Strangely, the other button on the same pane still reacts to mouse clicks. This happens only when I select a directory, but not when I choose a file. Also, it does not happen, when I click "Cancel" instead of "Open". Furthermore, the problem occurs only using the Firefox plugin, not in the AppletViewer. I even tried to remove the text field from the root pane and add a new one after the file chooser execution, but still it won't regain focus.
    Here's the stripped-down code:
    import java.awt.BorderLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JApplet;
    import javax.swing.JButton;
    import javax.swing.JFileChooser;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
    public class TestApplet extends JApplet {
        private static final long serialVersionUID = 1L;
        @Override
        public void init() {
            final JPanel rootPanel = new JPanel();
            rootPanel.setLayout(new BorderLayout());
            getContentPane().add(rootPanel);
            final JButton fileChooserButton = new JButton("Start");
            fileChooserButton.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    JFileChooser fc = new JFileChooser();
                    fc.setAcceptAllFileFilterUsed(false);
                    fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
                    fc.setMultiSelectionEnabled(false);
                    fc.showOpenDialog(rootPanel);
            JTextField textField = new JTextField();
            rootPanel.add(fileChooserButton, BorderLayout.CENTER);
            rootPanel.add(textField, BorderLayout.SOUTH);
    }And this is the applet.html:
    <applet code="TestApplet.class" codebase="file://home/administrator/workspace/Test/bin" width=100 height=50></applet> This concerns: Ubuntu 9.04 / Firefox 3.6.9 / JVM 1.6.0_20
    Any help or ideas for a workaround would be much appreciated...

    AndrewThompson64 wrote:
    JWS was available as a separate download since Java 1.2. It became bundled with the JRE around 1.4.2, not sure of the micro-version, but it was in the 1.4 era. 1.4 has been relegated to the 'obsolete' pile now, so I think you are safe expecting the end user to be prepared to update to 1.5+ if needed.You don't know my grandma: she isn't prepared to anything, but she wants things to just work ;-)
    For ensuring the user has a minimum of 1.5, see the [Java&#153; Rich Internet Applications Deployment Advice|http://download.oracle.com/javase/6/docs/technotes/guides/jweb/deployment_advice.html] for details of the deployJava.js script. It is useful for both applets and apps. deployed using JWS.
    Yes, I already use this script for my Applet, but I hadn't realized that it worked for JWS as well.
    Do you mean like a corporate intranet?Exactly. Another example could be centrally managed laptops connecting over Internet to your application (like the traveling salesman connecting to his task planner)
    ... Can you do a search of the bug DB and if nothing shows up, submit one? The only chance these things will get fixed is if they are reported.I agree with you on that question and I've already had a look (didn't find anything so far)
    Embedded applets are a PITA. I wouldn't disagree, but again, if you want to bring a rich client to the masses, sometimes that's the way to do it (unless you go for ActiveX, which is definitely not an option for me). Anyway, I'll give JWS a try.. and then I'll ask the customer help desk if it was a good idea...
    For example, is there any programmatic way to determine if the embedded applet is not acting as expected? If so, monitor that and on detection, pop a dialog to the user explaining the situation and offering the free floating version from a button click.Well, I have to think a bit more about this. Probably I will just to check if the text field gets the focus after a mouse click, by adding some kind of test inside a MouseListener. If it doesn't get the focus, I would be quite sure that there's a problem... I'll look into this.
    On the other hand, to work around the whole problem, I have found some Open Source Directory Chooser (http://sourceforge.net/projects/jfolderchooser), which looks nice at a first glance, but I didn't have the time to go into it in more detail. I'll just quote you here:
    I cannot say if this will fix the problem. Or perhaps it will fix the problem in that browser/JRE combo., but break it in another. ;)Words full of truth :)

  • Question-How to fix Robohelp8 window keeps focus when it shouldn't?

    I converted a robohelp 8 for word project to robohelp 8 for HTML this year.  The software GUI it is part of is created with PowerBuilder 12.1.  The HTML help works fine in the application, except that once the help window is opened, only that window has focus. If you navigate to another GUI window and keep the help opened, it remains in the back which is correct.  If you navigate back to the original GUI window, the help window is "stuck" on top where it originally was, when it should be in the background.  The old robohelp for word doesn't have this problem.  I have checked all the window properties settings, and all are basic default values.  I do have the "remember size and position" option turned on, so that you can move the help window out of the way of the GUI, and then it works fine.  But my developers want the focus issue to be fixed.  It occurs both in XP and  Windows 7.  Is this something I can fix in robohelp?  Or is it a PowerBuilder issue?
    I have another help project created with robohelp 8 html with same window properties & that one does not have this problem.  That GUI is created with Visual Studio 2008.
    Thank you very much!!
    Judy

    Hi Judy
    Likely you need to ask your developers to examine the calls for the application where things work as expected. My guess is that they will find there is a change they need to make in the way they call the help. There really isn't much in RoboHelp that influences this behavior. You can look at the extended properties for the window, but I'm doubtful you will find that anything has been set that would cause it.
    Cheers... Rick
    Helpful and Handy Links
    RoboHelp Wish Form/Bug Reporting Form
    Begin learning RoboHelp HTML 7, 8 or 9 within the day!
    Adobe Certified RoboHelp HTML Training
    SorcerStone Blog
    RoboHelp eBooks

  • List : Element Height , Textfield : Set Focus

    Hi,
    I am develping an application using Http connection. Where i use a List item to display options to be selected.
    My problem is the elements displayed in List are very close to each other and i would like to give space between them. Perhaps a line to seperate the list elements ( I tried \n)
    And another problem i face that, I like to set Keypad focus to a particular textfield in the form of 3 text fields
    Can any one help to achive these?
    Regards,

    Thanks. The DataGrid looks very nice compared to the standard List item comes in MIDP. I plan to use this :)
    I dont find setCurrentItem(Item) ; could you explain ?
    My objective is to create a mobile version of a web application.
    Sort of Meeting organizer. where I need to select a meeting from a list and update few fields of the meeting
    Database : SQL Server
    WebServer : Tomcat where i run servlets to communicate with the database
    The Servlet sends a delimited (:) text as output. Then the phone displays them as a list or in text boxes.
    Have any idea about doing this better? and easy? perhaps xml , web services i find complex to maintain and install
    //Regards

Maybe you are looking for

  • Red Hat (Enterprise Linux) and Hewlett Packard

    Dear HP, You folks seem to have made a real effort to get your printer drivers out there to all. I applaud you. Enlightened self-interest. It is now 2014. You offer me drivers for my new Color Laserjet printer.  Red Hat offers me drivers for HP print

  • Urgent Error : Make file in PRO*COBOL

    Hi All, We are trying to Make a COBOL file using Oracle 8.0.5 but ends with an error in a production environment. The OS is Solaris 8. cob : Library not found : -lsqlnet Make : fatal error : command failed for target "<Prog name> " I checked the envi

  • Tiff or psd trouble with fh11

    please help me, i have trouble with tiff or psd image, no problem when i imported that image, but when i add effect drop shadow or glow and other effect that object going blur, i try to clone that object before add shadhowing, i think it will be ok,

  • Only forms&reports 10g

    can I find an installer for forms&reports 10g only? I allready have JDeveloper and AS And is it compatible with a 9i database? thanks a lot!

  • Frame(sprite) animation delay problem

    import javax.microedition.lcdui.*; import javax.microedition.lcdui.game.*; public class ExampleTrialCanvas extends GameCanvas implements Runnable { private boolean isPlay; // Game Loop runs when isPlay is true private long delay; // To give thread co