简体   繁体   中英

Suppress default double-click event in SWT.CHECK Table

I am using a SWT Table styled with SWT.CHECK and SWT.FULL_SELECTION . I added a MouseListener to fill an output group, when a user double-clicks a table row. However, a double-click will also toggle the row's checkbox. Though I suppose this is intended behaviour of the target platform (Windows), I want to prevent the checkbox from toggling.

Is it possible to not make the checkbox toggle on double-click?

I figured out, that the Table implementation I was using added a SelectionListener that toggled the checkbox.

When I removed it, everything worked as expected:

  Listener[] listeners = table.getListeners(SWT.Selection);

  if (listeners.length > 0) {
     TypedListener typedListener = (TypedListener)listeners[0];

     SelectionListener selectionListener = (SelectionListener)typedListener.getEventListener();

     table.removeSelectionListener(selectionListener);
  }

Ain't a clean solution, but since I know that the object only has one SelectionListener at that time, it seems legitimate to remove it this way.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM