Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Nebula » Problem with shell closing after the grid drag detection mechanism being enabled and some grid colum
Problem with shell closing after the grid drag detection mechanism being enabled and some grid colum [message #587710] Wed, 16 January 2008 14:17
Eclipse UserFriend
Originally posted by: vye.maconomy.dk

Hi guys,

I faced the following problem: when I enable drag detection mechanism in
the grid and then click on some grid column header, then I cannot close
immediately the grid's shell: the first mouse click after click on the
header activates the shell, and only the second click on the
application's close button closes the application. This happens under
Windows platform. Here is the snippet for this problem (actually this is
GridSnippet1, modificated for drag detection support of the grid):

package snippets;

import org.eclipse.nebula.widgets.grid.Grid;
import org.eclipse.nebula.widgets.grid.GridColumn;
import org.eclipse.nebula.widgets.grid.GridItem;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DragDetectEvent;
import org.eclipse.swt.events.DragDetectListener;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

/**
* Creates a simple grid and a button for focusing and selection of
* the first cell of the grid. */
public class Snippet001GridDragDetectListener {

/**
* Main entry.
* @param args command line arguments
*/
public static void main(String[] args) {
final Display display = new Display();
final Shell shell = new Shell(display);
shell.setLayout(new FillLayout());

final Grid grid = new Grid(shell, SWT.BORDER | SWT.V_SCROLL |
SWT.H_SCROLL);
grid.setHeaderVisible(true);
final GridColumn column = new GridColumn(grid, SWT.NONE);
column.setTree(true);
column.setText("Column 1");
column.setWidth(100);
final GridItem item1 = new GridItem(grid, SWT.NONE);
item1.setText("Root Item");
final GridItem item2 = new GridItem(item1, SWT.NONE);
item2.setText("Second item");
final GridItem item3 = new GridItem(item2, SWT.NONE);
item3.setText("Third Item");

// The following code was inserted to enable
// drag detection listening mechanism
// in the grid.
grid.setDragDetect(true);
// If you add at least one drag detection listener
// to the grid and then click on the grid column
// header, then the grid's shell loses its active state,
// that is, for example, you cannot then close the
// demo with one mouse click (first mouse
// click afterwards activates the grid's shell, and
// only second mouse click closes the demo itself).
grid.addDragDetectListener(new DragDetectListener() {
/** {@inheritDoc} */
public void dragDetected(final DragDetectEvent event) { }
});

shell.setSize(200, 200);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}

Does somebody know why it might be the case?

Best regards,

Vadym Yepishov
Previous Topic:Removing Items from Gallery
Next Topic:Brainstorming: grid as a spreadsheet
Goto Forum:
  


Current Time: Sun Nov 27 15:36:54 GMT 2022

Powered by FUDForum. Page generated in 0.01996 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top