Combobox removing focus?

Why when I use the combobox component does it remove focus
from other movieclips?? For instance...I have a button with
onRollOver and onRollOut functions. These work fine, but once I
click on a combobox, they break...and won't work.
I've looked in other places but I haven't found a fix for
this yet. Doing setfocus(this) only puts a ugly yellow highlight
box around my button, and then kills the swf with an infinite loop.
Any ideas?

While it depends partly on what is outside the textfield, one way would be to add an event listener to the stage and then check what was clicked.  If it happened to be the stage, set the focus onto the stage.
stage.addEventListener(MouseEvent.MOUSE_UP, focusStage);
function focusStage(evt:MouseEvent):void {
    if(evt.target == stage){
       stage.focus = stage;

Similar Messages

  • Combobox removing focus!? help!

    Why when I use the combobox component does it remove focus
    from other movieclips?? For instance...I have a button with
    onRollOver and onRollOut functions. These work fine, but once I
    click on a combobox, they break...and won't work.
    I've looked in other places but I haven't found a fix for
    this yet. Doing setfocus(this) only puts a ugly yellow highlight
    box around my button, and then kills the swf with an infinite loop.
    Any ideas?

    hi, hold your data in a Hashtable with the value as key
    and the visible text as value,use a renderer for the combobox like here
    class MyCellRenderer extends JLabel implements ListCellRenderer {
    public MyCellRenderer() {
    setOpaque(true);
    public Component getListCellRendererComponent(
    JList list,
    Object value,
    int index,
    boolean isSelected,
    boolean cellHasFocus)
    setText(value.toString());
    setBackground(isSelected ? Color.red : Color.white);
    setForeground(isSelected ? Color.white : Color.black);
    return this;
    in the method getListCellRendererComponent you get your hashtable as object parameter,get the visible text from the hashtable and call setText (..)
    you can also make a combined String with value and text
    and take only the visible text in the renderer(this solution is not so bombastic as before)

  • [Flex 4.5.1] How to remove focus from TextInput on mouse click outside of it?

    For me clicking outside of a TextInput should always remove focus from it, only only if you click on another TextInput or Button.
    I don't see any simple event like MouseEvent.MOUSE_CLICK_OUTSIDE - which would definitely simplify things.. I wonder why there isn't such event. Well anyway I can't find any other similar event and I can't figure out an easy way to do this. I also wonder why I couldn't find a solution to this on the web easily... Well anyway...
    Does someone know how to do that in a convenient way?
    Thanks!

    ok I understand why is that. For example I have a TextInput now where the user enters number through buttons which have mouseFocusEnabled = false, so the TextInput doesn't lose focus. But on a TabBar I had to set mouseFocusEnabled = true or when I switched between tabs -> switches between states, I could still type in the TextInput in the previous tab cause it didn't lose focus. Maybe TabBar's default value of that property is wrongly set to false.
    Anyway, not losing focus when clicking outside is still weird. Take for example this forum, if I click outside of the box I am currently writing this, I lose focus. It's how things usually work. And flex focus is designed to work backwards to what people are used to, no matter as I already pointed out I understand there are cases it comes in handly. I hope I don't sound bad but take it just as a suggestion please that maybe if it is redesigned like this: clicking on component gets focus, clicking outside loses focus. But if you click on a button for example and you want to keep the focus on a TextInput cause you add some text, you should be able to set a property on the Button like maintainCurrentFocus = true (false by default), which would make clicking on the Button not shift the focus to it or set it to null if the component is a group that has some rect background for example, but maintain the focus on the TextInput.
    I could be missing something about the current design of how the focus works in flex, but from my point of view at the moment, the design I describe to use is just like how I am usually used to be working with focus as a user, not as developer.
    Maybe you could agree or maybe you know some reason by which things are how they are at the moment that I don't see. But if you think I make sense please let me know, maybe I could fill a minor enhancement request for that ?

  • How to remove focus from a Ring Control in a PDA application?

    Hello,
        In a PDA application, i have observed that when we select a pull-down Ring control, the focus is retained in the control and the text of the control appears highlighted. The only way out is to tap an empty portion of the PDA application screen to remove focus from the control. Is there any way to avoid this? Is there a method to remove focus from the control programatically?
    Note: Version of LabVIEW that we are using: LabVIEW 8.5 Professional Development System for Windows Vista/XP/2000 and LabVIEW 8.5 PDA Module for Windows Mobile.
    Thanks & Regards,
    Subhashini

    Hi Vsh,
        Thanks for ur response. Setting the key focus property node of the ring control to false removed the focus from the control. I guess it was a silly question (have started LabVIEW devp. recently).
    Thanks & Regards,
    Subhashini

  • Remove focus from JButton?

    I am starting a new thread related to my previous thread.
    I came to realize that when I call a game object from the GUI menu by clicking on "New Game" button, the focus is set to the button. I found it by using the method, if(newButton.hasFocus()).
    However, my problem is not yet finished. I tried game.requestFocus(); also.
    But still, the focus is not removed.
    Can n e one pls let me know if there is a way to remove focus from the damn button?
    Thanks.                         

    button.setFocusable( false );Will pevent the button from maintaining focus.

  • Remove focus from combobox

    Hi,
    Iam working with SAP B1 2007 .
    A combobox is populated with items.After the user selects the item in it,the focus must be removed from that combobox control to next textbox control.Can anyone suggest me what can I do for this.
    Thanks In Advance

    Hi ,
    Catch the event combo select and then emulate a click on the text control
    using
    oform.Items.Item("textControl").Click
    regards
    Edy

  • Set border color of editable ComboBox on focus

    What I want to do, is set BorderBrush of editable ComboBox. I'm using slightly modified default WPF templates. They are structured like below:
    <ControlTemplate x:Key="ComboBoxEditableTemplate" TargetType="{x:Type ComboBox}">
    <Grid x:Name="templateRoot" ...>
    <ToggleButton x:Name="toggleButton" ... />
    <Border x:Name="border" ...>
    <TextBox x:Name="PART_EditableTextBox" ... />
    <!-- textbox with IsFocused property which should be focus trigger -->
    </Border>
    </Grid>
    </ControlTemplate>
    ToggleButton template:
    <ControlTemplate TargetType="{x:Type ToggleButton}">
    <Border x:Name="templateRoot" ...> <!-- first border brush I want to set on focus -->
    <Border x:Name="innerBorder" ...> <!-- second border brush I want to set on focus -->
    <Border x:Name="splitBorder" ...>
    <Path x:Name="arrow" ... />
    </Border>
    </Border>
    </Border>
    </ControlTemplate>
    And now, what should happen.
    When PART_EditableTextBox.IsFocused is equal to true then set
    templateRoot.BorderBrush and innerBorder.BorderBrush to another color (for example red and blue).
    It would be very simple if there was only one BorderBrush to set, because I could use
    TemplateBinding to bind this property to ToggleButton element.
    For me, the problem are nested templates. I don't know how to refer to inside of another template.
    I hope you can help me.
    It would be very good if I didn't need to use C# code, just XAML.

    >>I don't know how to refer to inside of another template.
    You cannot. But since the PART_EditableTextBox is part of the ControlTemplate of the ComboBox you could add the trigger to this control template and then for example set the BorderBrush property and the Background propery of the ToggleButton and bind these
    to the BorderBrush properties of the Borders in its ControlTemplate:
    <ControlTemplate x:Key="ComboBoxEditableTemplate" TargetType="{x:Type ComboBox}">
    <TextBox x:Name="PART_EditableTextBox" ... />
    <ToggleButton x:Name="toggleButton" ... />
    <ControlTemplate.Triggers>
    <Trigger Property="IsFocused" Value="True" SourceName="PART_EditableTextBox">
    <Setter Property="BorderBrush" TargetName="toggleButton" Value="Red"/>
    <Setter Property="Background" TargetName="toggleButton" Value="Blue" />
    </Trigger>
    </ControlTemplate.Triggers>
    <Style x:Key="ComboBoxToggleButton" TargetType="{x:Type ToggleButton}">
    <Setter Property="OverridesDefaultStyle" Value="true"/>
    <Setter Property="IsTabStop" Value="false"/>
    <Setter Property="Focusable" Value="false"/>
    <Setter Property="ClickMode" Value="Press"/>
    <Setter Property="Template">
    <Setter.Value>
    <ControlTemplate TargetType="{x:Type ToggleButton}">
    <Border x:Name="templateRoot" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="2">
    <Border x:Name="innerBorder" BorderBrush="{TemplateBinding Background}" BorderThickness="2">
    <Border x:Name="splitBorder">
    <Path x:Name="Arrow" Data="{StaticResource DownArrowGeometry}"
    Fill="Black" HorizontalAlignment="Center" Margin="0,1,0,0" VerticalAlignment="Center"/>
    </Border>
    </Border>
    </Border>
    </ControlTemplate>
    </Setter.Value>
    </Setter>
    </Style>
    If you don't want to use the Background property for this, the other option is to create your own custom class that derives from the ToggleButton class and add a dependency property called "InnerBackground" or something to this class and replace
    the ToggleButton with your custom ToggleButton and replace the binding to the Background property with a binding to the new dependency property and set this one in the control template for the ComboBox.
    Hope that helps.
    Please remember to close your threads by marking helpful posts as answer and/or helpful and please start a new thread if you have a new question.

  • Problem removing focused object from a table

    Hi.
    I have a problem removing a component that is focused from a table. The
    whole row is removed except a single component (JSpinner) in one row.
    My table has three columns, the first two are String fields
    (not editable) and the last is a JSpinner. Since there is no
    Default cell renderer or cell editor for JSpinner I had to
    create them.
    So, if no element of the row is focused then calling the function:
    public void clearTable() {
    setVisible(false);
    dataVector.removeAllElements(); // clear data vector
    setVisible(true);
    works just fine
    but if a spinner in a row is focused them that spinner is left alone "floating" on an otherwise empty table.
    Questions:
    1) Any one has an ideia of what might be the problem?
    2) Do I have to play with Focus to solve this? (hate the idea,
    since always been told to avoid messing with focus, because
    of the problems it normally brings)
    Thanks in advance for the help,
    Rgds,
    Jorge

    The problem is that you need to properly stop the editing operation first.if( myTable.isEditing() ) {
        // If you want to throw away any edits use...
        myTable.getCellEditor().cancelCellEditing();
        // If you want to apply any edits, then end use...
        myTable.getCellEditor().stopCellEditing();

  • Spark ComboBox/TextArea focus interaction

    I have a ComboBox set up to change the font size of the text in a TextArea.  If I set the ComboBox to return focus to the TextArea in its change event, it causes the ComboBox to require 2 clicks to make a selection.  Here's a simple application showing the behaviour that I'm seeeing:
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                      xmlns:s="library://ns.adobe.com/flex/spark"
                      xmlns:mx="library://ns.adobe.com/flex/mx">
         <fx:Script>     <![CDATA[
                   import flashx.textLayout.edit.IEditManager;
                   import flashx.textLayout.formats.TextLayoutFormat;
                   protected function sizeChange():void {
                        var format:TextLayoutFormat = new TextLayoutFormat();
                        format.fontSize = comboBox.selectedItem;
                        IEditManager(textArea.textFlow.interactionManager).applyLeafFormat(format);
                        textArea.setFocus();  //Without this line, the combobox works as expected.  With it, you must click on your selection twice to close the combobox
         ]]>     </fx:Script>
         <s:VGroup>
              <s:TextArea id="textArea" />
              <s:ComboBox id="comboBox" change="sizeChange()">
                   <s:dataProvider>
                        <s:ArrayList>
                             <fx:int>10</fx:int>
                             <fx:int>12</fx:int>
                             <fx:int>14</fx:int>
                             <fx:int>16</fx:int>
                             <fx:int>24</fx:int>
                             <fx:int>32</fx:int>
                        </s:ArrayList>
                   </s:dataProvider>
              </s:ComboBox>
         </s:VGroup>
    </s:Application>

    Looks like an editor interaction.  I wouldn't want the ComboBox to ever get
    focus so I'd skip the setFocus call and just set tabFocusEnabled=false and
    mouseFocusEnabled = false;

  • SetContentAreaFilled removes focus painting

    I have a JButton whose background and border I would like to be transparent/removed. However, I want to retain the focus painting for the button.
    When I use setContentAreaFilled(false), the background and border are properly not displayed. However, focus is no longer painted either, even if I call setFocusPainted(true).
    I even tried calling:
    setBorderPainted(true);
    setOpaque(false);
    but as far as I can tell, these calls did nothing.
    Please note that I'm using the Windows look & feel for this window, which may be the cause of the problem. However, within that context, does anyone have any recommendations for resolving this?
    Thanks much!

    setFocusPainted(true)
    Some look and feels might not paint focus state; they will ignore this property.
    So its entirely a look and feel issue, i faced the same problem once with motif look.

  • Can't remove focus when validating

    I have a validation on a JTextField that stops the user focussing on the next input field until the correct data is entered. Its simple and works like this:
    private void docnumFieldFocusLost(java.awt.event.FocusEvent evt)
        if (!evt.isTemporary())
          if (!validDocnum())
           docnumField.requestFocusInWindow();
           docnumField.setBackground(new Color(251, 51, 0));
           displayMsg(errortype, title, msg);
      }One option I want to give the user is to abandon the input altogether by clicking a Reset button (to return the field to blank) or Exit button (to leave the GUI completely). But I cant get out of the original focus on the docnumField.
    I have tried:
    private void resetButtonMouseClicked(java.awt.event.MouseEvent evt)
        docnumField.setRequestFocusEnabled(false);
        docnumField.setText("");
        resetValues();
      }but the attempt to focus on the resetButton component fails because the other focus can't be broken. I would be most thankful for a suggestion to break this 'loop'.

    Did you remove camera from the multitask bar?

  • Remove Focus from Main Frame after Jinternal Frame is opened.

    Hi,
    I want to restrict the user to change any thing on main frame once the JInternalFrame is opened (you can see same effect when we execute JOptionPane where focus on main is not retain untill you close the JOptionPane).
    I have written following code to listen the JInternalFrame event
    conn_prop.addInternalFrameListener(new InternalFrameListener(){
    @Override
    public void internalFrameActivated(InternalFrameEvent e) {
    // TODO Auto-generated method stub
    @Override
    public void internalFrameClosed(InternalFrameEvent e) {
    // TODO Auto-generated method stub
    @Override
    public void internalFrameClosing(InternalFrameEvent e) {
    // TODO Auto-generated method stub
    @Override
    public void internalFrameDeactivated(InternalFrameEvent e) {
    // TODO Auto-generated method stub
    @Override
    public void internalFrameDeiconified(InternalFrameEvent e) {
    // TODO Auto-generated method stub
    @Override
    public void internalFrameIconified(InternalFrameEvent e) {
    // TODO Auto-generated method stub
    @Override
    public void internalFrameOpened(InternalFrameEvent e) {
    // TODO Auto-generated method stub
    }}); I tried setEnabled(false) but this is paralyzing entire application
    what piece of code should i write to do that........
    thanks in advance.

    That is not how a JInternalFrame is meant to be used. Read the Swing tutorial on "Using Internal Frames".
    Use a modal JDialog.

  • StopCellEditing () removes focus from table

    Hi,
    i have created a custom cellEditor, when the user presses enter a popupwindow is shown which shows a list of possible values.
    When the popup closes i call stopCellEditing (), in a DefaultCellEditor the focus then remains on the table...but in this case the focus just disappears...
    Anybody with the same focusproblems?
    Nick

    Hi,
    i have created a custom cellEditor, when the user presses enter a popupwindow is shown which shows a list of possible values.
    When the popup closes i call stopCellEditing (), in a DefaultCellEditor the focus then remains on the table...but in this case the focus just disappears...
    Anybody with the same focusproblems?
    Nick

  • Removing focus from a node

    I have a frame in which a scrollpane hold a jtree.
    I picked up the following code from the forum for making sure that only when the right click is on a node, the popupmenu is displayed.
    public void mouseReleased(MouseEvent e) {
                if (e.getButton() == MouseEvent.BUTTON3) {
                    TreePath closestTreePath = tree.getClosestPathForLocation(e.getPoint(), e.getPoint());
                    if (closestTreePath != null) {
                        tree.setSelectionPath(closestTreePath);
                         // select the row in the tree for the path
                        selectedRow = tree.getRowForPath(closestTreePath);
                        YourNode node = (YourNode) closestTreePath.getLastPathComponent();
                       // assuming your popup menu is already created somewhere else
                       popupMenu.show(deviceTree, pt.x, pt.y);
                        selectedRow = -1;
    }by codecraig
    But now the problem is that whenever i do right click anywhere on the tree a node gets selected and the popupmenu is displyed. i want to display the right click is on the node.
    here is my code
    import javax.swing.*;
    import javax.swing.tree.*;
    import java.awt.event.*;
    public class tree_right_click
         //JPopupMenu popupmenu = new JPopupMenu();
         JTree mytree;
         SysPopupListener s = new SysPopupListener();
         public tree_right_click()
              DefaultMutableTreeNode root = new DefaultMutableTreeNode("root");
              DefaultMutableTreeNode l1 = new DefaultMutableTreeNode("level1");
              DefaultMutableTreeNode l2 = new DefaultMutableTreeNode("level2");
              mytree=new JTree(root);
              mytree.addMouseListener(s);
              root.add(l1);
              l1.add(l2);
              JScrollPane treeview = new JScrollPane(mytree);
              JFrame fr = new JFrame("My Frame");
              fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              fr.getContentPane().add(treeview);
              fr.setSize(300,300);
              fr.setVisible(true);
              public static void main(String args[])
              new tree_right_click();
    class SysPopupListener extends MouseAdapter
         JPopupMenu popupmenu = new JPopupMenu();
         SysPopupListener()
              JMenuItem part = new JMenuItem("Add detail 1");
              JMenuItem part2 = new JMenuItem("Add detail 2");
              part.addMouseListener(this);
              part2.addMouseListener(this);
              popupmenu.add(part);
              popupmenu.add(part2);
         public void mousePressed(MouseEvent e)
              maybeshowpopup(e);
         public void mouseReleased(MouseEvent e)
              maybeshowpopup(e);
         void maybeshowpopup(MouseEvent e)
              if(e.isPopupTrigger())
                   JTree t = (JTree)e.getComponent();
                   TreePath closestTreePath = t.getClosestPathForLocation(e.getX(), e.getY());
                if (closestTreePath != null) {
                    t.setSelectionPath(closestTreePath);
                     // select the row in the tree for the path
                    int selectedRow = t.getRowForPath(closestTreePath);
                    DefaultMutableTreeNode n = (DefaultMutableTreeNode) closestTreePath.getLastPathComponent();
                    System.out.print(n);
                   // assuming your popup menu is already created somewhere else
                    popupmenu.show(e.getComponent(),e.getX(),e.getY());
                    selectedRow = -1;
    }Please help,
    thanks in advance,
    Puneet

    I made some changes to your code and seems to be working like this:
              if(e.isPopupTrigger()) {
                   JTree t = (JTree)e.getComponent();
                   TreePath closestTreePath = t.getClosestPathForLocation(e.getX(), e.getY());
                   if (closestTreePath != null) {
                        t.setSelectionPath(closestTreePath);
                        // select the row in the tree for the path
                        int selectedRow = t.getRowForPath(closestTreePath);
                        DefaultMutableTreeNode n = (DefaultMutableTreeNode) closestTreePath.getLastPathComponent();
                        System.out.print(n);
                        // assuming your popup menu is already created somewhere else
                        popupmenu.show(e.getComponent(),e.getX(),e.getY());
                        selectedRow = -1;
                   JTree t = (JTree)e.getComponent();
                   TreePath path = t.getPathForLocation(e.getX(), e.getY());
                   if (path != null) {
                        popupmenu.show(e.getComponent(),e.getX(),e.getY());
              }

  • Combobox help

    Why when I use the combobox component does it remove focus
    from other movieclips?? For instance...I have a button with
    onRollOver and onRollOut functions. These work fine, but once I
    click on a combobox, they break...and won't work.
    I've looked in other places but I haven't found a fix for
    this yet. Doing setfocus(this) only puts a ugly yellow highlight
    box around my button, and then kills the swf with an infinite loop.
    Any ideas?

    Your question is very vague and badly phrased. Why don't you post some code to show what you've done and how you're inserting values into the DB right now?
    People on the forum help others voluntarily, it's not their job.
    Help them help you.
    Learn how to ask questions first: http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch
    (Yes I know it's on JavaRanch but I think it applies everywhere)
    ----------------------------------------------------------------

Maybe you are looking for