PDA

View Full Version : WindowMaximizeOnHeaderDoubleclick



Arno.Nyhm
7 Aug 2009, 5:59 AM
if you like to have the function to double click on a header and then the window should maximize and restore then is this helper class for you:

WindowMaximizeOnHeaderDoubleclick

code improvements are welcome :-)



package org.yournamehere.client.gui.components;

import com.extjs.gxt.ui.client.event.BaseEvent;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.widget.Window;
import com.google.gwt.user.client.Event;

/**
*
* @author anonym
*/
public class WindowMaximizeOnHeaderDoubleclick {

private WindowMaximizeOnHeaderDoubleclick() {
}

/**
*
* @param window
*/
public static void applyTo(final Window window) {
window.getHeader().addListener(Events.Render, new Listener<BaseEvent>() {

public void handleEvent(BaseEvent be) {
window.getHeader().el().addEventsSunk(Event.ONDBLCLICK);
}
});
window.getHeader().addListener(Events.OnDoubleClick, new Listener<BaseEvent>() {

public void handleEvent(BaseEvent be) {
if (window.isMaximized()) {
window.restore();
} else {
window.maximize();
}
}
});
}
}

usage:



package org.yournamehere.client.forum.code.snippets;

import com.extjs.gxt.ui.client.event.BaseEvent;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.widget.Html;
import com.extjs.gxt.ui.client.widget.Window;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.Event;

/**
*
* @author anonym
*/
public class ForumThread76937 implements EntryPoint {

public void onModuleLoad() {
Window window = new MyFormWindow();
window.show();
}

class MyFormWindow extends Window {

MyFormWindow() {
setMaximizable(true);
add(new Html("Test"));

WindowMaximizeOnHeaderDoubleclick.applyTo(this);
}
}
}

Arno.Nyhm
7 Aug 2009, 7:07 AM
it looks there is a shorter solution there:

I wanna WINDOW double click is maximum.
http://www.extjs.com/forum/showthread.php?p=369321#post369321