Skip to content

Commit

Permalink
fix SWT table/tree control SelectionListener on Mac (#1079)
Browse files Browse the repository at this point in the history
Fix SWT table/tree control SelectionListener on Mac

SelectionEvent.item in callback method widgetSelected now contains the
current selected item

Fixes: #1052

---------

Co-authored-by: Tobias Melcher <tobias.melcher@sap.com>
  • Loading branch information
tobiasmelcher and tobias-melcher authored Apr 4, 2024
1 parent 91b51cb commit 9719a2f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3477,6 +3477,9 @@ void tableViewSelectionDidChange (long id, long sel, long aNotification) {

@Override
void tableViewSelectionIsChanging (long id, long sel, long aNotification) {
// tableViewSelectionIsChanging is called when pressing ARROW_DOWN, ARROW_UP key
// don't run sendSelection because it would then gather the "old" incorrect selected row
if (keyDown) return;
didSelect = true;
sendSelection();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public class Tree extends Composite {

/* Used to control drop feedback when DND.FEEDBACK_EXPAND and DND.FEEDBACK_SCROLL is set/not set */
boolean shouldExpand = true, shouldScroll = true;

boolean keyDown;
final int nativeItemHeight;

static int NEXT_ID;
Expand Down Expand Up @@ -2108,7 +2108,9 @@ boolean isTrim (NSView view) {
@Override
void keyDown(long id, long sel, long theEvent) {
ignoreSelect = preventSelect = false;
keyDown = true;
super.keyDown(id, sel, theEvent);
keyDown = false;
}

@Override
Expand Down Expand Up @@ -2463,6 +2465,9 @@ void outlineViewSelectionDidChange (long id, long sel, long notification) {

@Override
void outlineViewSelectionIsChanging (long id, long sel, long notification) {
// outlineViewSelectionIsChanging is called when pressing ARROW_DOWN, ARROW_UP key
// don't run sendSelection because it would then gather the "old" incorrect selected row
if (keyDown) return;
didSelect = true;
sendSelection ();
}
Expand Down

0 comments on commit 9719a2f

Please sign in to comment.