Revision 1582

View differences:

trunk/libraries/libIverUtiles/src/com/iver/utiles/swing/JComboBox.java
115 115
    public class MyKeyListener implements KeyListener {
116 116
        private int lastCaretPosition = 0;
117 117
        private String lastText = "";
118
        private boolean bAutocompletar=true;
118 119

  
119 120
        /**
120 121
         * Devuelve dada una String, la String del modelo que empieza por dicha
......
145 146
            String texto = jtext.getText();
146 147

  
147 148
            String text = isInModel(texto);
148

  
149
            
149 150
            if (text != null) {
150 151
                int caretPos = texto.length();
151 152
                jtext.setText(text);
......
161 162
        public void keyPressed(KeyEvent e) {
162 163
            JTextField jtext = (JTextField) JComboBox.this.getEditor()
163 164
                                                          .getEditorComponent();
164

  
165
            if (e.getKeyCode() == KeyEvent.VK_BACK_SPACE) {
166
                if ((lastCaretPosition >=0) && 
165
            bAutocompletar = true;
166
            if ((e.getKeyCode() == KeyEvent.VK_BACK_SPACE)
167
                    || (e.getKeyCode() == KeyEvent.VK_DELETE))
168
            {
169
                bAutocompletar = false;
170
                /* if ((lastCaretPosition >=0) && 
167 171
                        (lastCaretPosition <= jtext.getText().length()))
168
                        	jtext.setCaretPosition(lastCaretPosition);
172
                        	jtext.setCaretPosition(lastCaretPosition); */
169 173
            }
170 174
        }
171 175

  
......
177 181
                                                          .getEditorComponent();
178 182
            String texto = jtext.getText().substring(0, jtext.getCaretPosition());
179 183

  
184
            if (!bAutocompletar) return;
180 185
            String text = isInModel(texto);
181 186

  
182 187
            if (!jtext.getText().equals(lastText) && (text != null)) {

Also available in: Unified diff