Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    events to Window

    Hello,

    I am using
    SmartClient Version: v8.3p_2013-04-19/PowerEdition Deployment (built 2013-04-19)

    I am having trouble getting the event to "hide" my window when I want to.

    I have a class
    Code:
    public class SearchWindowArea extends Window {
    ...
    This class has some things displayed in it. Including
    Code:
    	TextItem textItem = new TextItem();
    	ListGrid listGrid = new ListGrid();
    We show the listGrid when the user types some text in the textItem. And when the user moves outside the "Window" class I have AND (and this is the hard part) select somewhere else in the parent of Window. I want to "hide" the listGrid in window.

    How can I trap ALL events that mouse makes so that I can have listGrid hidden when the user clicks outside of it.

    I have added various handlers to listgird and window and not managed to get it right.

    Here are some of the handlers I tried. Is there anyway to make this posting window on the thread wider? So that my code below is not wrapped so oddly?

    Thanks,
    Evan

    Code:
    	private void setupHideListGridHandlers() {
    		// TODO
    		// What we want is ALL mouse events to be caught by the window which can then figure out if it wants to hide itself.
    		// So I "think" a way is through this.addEvent would be what we want to try using.
    		// Not sure how to do this, might take some thought...
    
    		// not sure this is what we want
    		ClickHandler clickHandlerWindow = new ClickHandler() {
    			@Override
    			public void onClick(ClickEvent event) {
    				if (!(getCurrentGrid().containsEvent() || toolStrip.containsEvent())) {
    					forceHideGrid();
    				}
    			}
    		};
    		this.addClickHandler(clickHandlerWindow);
    
    		FocusChangedHandler focusChangedHandler1 = new FocusChangedHandler() {
    			@Override
    			public void onFocusChanged(FocusChangedEvent event) {
    				hideTheListGrid();
    			};
    		};
    		this.addFocusChangedHandler(focusChangedHandler1);
    
    		FocusChangedHandler focusChangedHandler2 = new FocusChangedHandler() {
    			@Override
    			public void onFocusChanged(FocusChangedEvent event) {
    				hideTheListGrid();
    			};
    		};
    		listGrid.addFocusChangedHandler(focusChangedHandler2);
    		treeGrid.addFocusChangedHandler(focusChangedHandler2);
    
    		BlurHandler blurHandler = new BlurHandler() {
    			@Override
    			public void onBlur(BlurEvent event) {
    				hideTheListGrid();
    			}
    		};
    		textItem.addBlurHandler(blurHandler);
    
    		// This is the one that really controls the list grid
    		MouseOutHandler handlerMouseOutHandler = new MouseOutHandler() {
    			@Override
    			public void onMouseOut(MouseOutEvent event) {
    				hideTheListGrid();
    			}
    
    		};
    		this.addMouseOutHandler(handlerMouseOutHandler);
    
    		SelectionChangedHandler selectionChangedHandler = new SelectionChangedHandler() {
    			@Override
    			public void onSelectionChanged(SelectionEvent event) {
    				textItem.focusInItem();
    			}
    
    		};
    		listGrid.addSelectionChangedHandler(selectionChangedHandler);
    		
    	}
    Last edited by Isomorphic; 10 Jun 2013, 08:31. Reason: Formatting Code blocks

    #2
    The most common approach for this sort of thing is to use the ClickMask -- you can call "showClickMask" to get a notification (and if required the option to suppress default behavior) when the user attempts to interact with the page outside some specific component.

    Also on formatting code - you can enclose your code block in [code] tags and it'll format correctly. We've edited your original post to do this

    Regards
    Isomorphic Software

    Comment

    Working...
    X