Show
Ignore:
Timestamp:
07/15/08 08:44:30 (4 months ago)
Author:
jouni.koivuviita@…
Message:

Fixes #1941: Combobox should close the dropdown menu when pressing ESC-key

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/com/itmill/toolkit/terminal/gwt/client/ui/IFilterSelect.java

    r5068 r5104  
    158158            // page 
    159159            if (matches <= PAGELENTH) { 
    160                 DOM.setStyleAttribute(status, "display", "none"); 
    161                 DOM.setStyleAttribute(up, "display", "none"); 
    162                 DOM.setStyleAttribute(down, "display", "none"); 
    163             } else { 
    164                 DOM.setStyleAttribute(status, "display", ""); 
    165                 DOM.setStyleAttribute(up, "display", ""); 
    166                 DOM.setStyleAttribute(down, "display", ""); 
     160                setPagingEnabled(false); 
     161            } else { 
     162                setPagingEnabled(true); 
    167163            } 
    168164            setPrevButtonActive(first > 1); 
     
    263259            } 
    264260            if (paging) { 
    265                 DOM.setStyleAttribute(down, "display", "block"); 
    266                 DOM.setStyleAttribute(up, "display", "block"); 
    267                 DOM.setStyleAttribute(status, "display", "block"); 
     261                DOM.setStyleAttribute(down, "display", ""); 
     262                DOM.setStyleAttribute(up, "display", ""); 
     263                DOM.setStyleAttribute(status, "display", ""); 
    268264            } else { 
    269265                DOM.setStyleAttribute(down, "display", "none"); 
     
    705701                    break; 
    706702                } 
     703            case KeyboardListener.KEY_ESCAPE: 
     704                if (currentSuggestion != null) { 
     705                    String text = currentSuggestion.getReplacementString(); 
     706                    tb.setText((text.equals("") ? emptyText : text)); 
     707                    // TODO add/remove class CLASSNAME_EMPTY 
     708                    selectedOptionKey = currentSuggestion.key; 
     709                } else { 
     710                    tb.setText(emptyText); 
     711                    // TODO add class CLASSNAME_EMPTY 
     712                    selectedOptionKey = null; 
     713                } 
     714                lastFilter = ""; 
     715                suggestionPopup.hide(); 
     716                break; 
    707717            default: 
    708718                filterOptions(currentPage);