mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-26 09:43:53 +02:00
Launch Bar: ui tweaks for proper re-sizing and keyboard events
- fixed issues when list is not drawn properly - fixed that Esc does not work to close pop up sometimes - fixed filtering for list with edit button - fixed layout issues when only one item in the list and filter becomes visible (filter is disabled in this case) Change-Id: I562f12df8326b4efecf75150b57b699c53d398da
This commit is contained in:
parent
40b6b6c05c
commit
faf222b8f2
2 changed files with 28 additions and 17 deletions
|
@ -271,6 +271,9 @@ public class FilterControl extends Composite {
|
||||||
} else if (e.detail == SWT.TRAVERSE_ARROW_NEXT) {
|
} else if (e.detail == SWT.TRAVERSE_ARROW_NEXT) {
|
||||||
listViewer.setFocus();
|
listViewer.setFocus();
|
||||||
updateListSelection(false);
|
updateListSelection(false);
|
||||||
|
} else if (e.detail == SWT.TRAVERSE_ESCAPE) {
|
||||||
|
listViewer.setDefaultSelection(new StructuredSelection());
|
||||||
|
e.doit = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -137,7 +137,28 @@ public class LaunchBarListViewer extends StructuredViewer {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private KeyListener lisItemKeyListener = new KeyListener() {
|
||||||
|
@Override
|
||||||
|
public void keyReleased(KeyEvent e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void keyPressed(KeyEvent e) {
|
||||||
|
if (e.character != 0 && e.character >= 0x20 && !filterControl.isVisible()) {
|
||||||
|
if (listItems.length <= 1)
|
||||||
|
return; // no filter for 1 item!
|
||||||
|
// enable filter control and send the character there
|
||||||
|
filterControl.setVisible(true);
|
||||||
|
filterControl.setFocus();
|
||||||
|
filterControl.getParent().layout(true);
|
||||||
|
filterControl.getFilterText().setText(e.character + "");
|
||||||
|
filterControl.getFilterText().setSelection(1);
|
||||||
|
} else if (e.character == SWT.ESC) {
|
||||||
|
setDefaultSelection(new StructuredSelection());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
private class ListItem extends Composite {
|
private class ListItem extends Composite {
|
||||||
|
@ -171,6 +192,7 @@ public class LaunchBarListViewer extends StructuredViewer {
|
||||||
GC gc = e.gc;
|
GC gc = e.gc;
|
||||||
gc.setForeground(outlineColor);
|
gc.setForeground(outlineColor);
|
||||||
gc.drawLine(0, size.y - 1, size.x, size.y - 1);
|
gc.drawLine(0, size.y - 1, size.x, size.y - 1);
|
||||||
|
System.out.println(ListItem.this.index);
|
||||||
if (label == null)
|
if (label == null)
|
||||||
lazyInit();
|
lazyInit();
|
||||||
}
|
}
|
||||||
|
@ -235,28 +257,13 @@ public class LaunchBarListViewer extends StructuredViewer {
|
||||||
editButton.setBackground(backgroundColor);
|
editButton.setBackground(backgroundColor);
|
||||||
editButton.addMouseTrackListener(listItemMouseTrackListener);
|
editButton.addMouseTrackListener(listItemMouseTrackListener);
|
||||||
editButton.addTraverseListener(listItemTraverseListener);
|
editButton.addTraverseListener(listItemTraverseListener);
|
||||||
|
editButton.addKeyListener(lisItemKeyListener);
|
||||||
} else {
|
} else {
|
||||||
// add traverse listnener to control which will have keyboard focus
|
// add traverse listnener to control which will have keyboard focus
|
||||||
addTraverseListener(listItemTraverseListener);
|
addTraverseListener(listItemTraverseListener);
|
||||||
|
addKeyListener(lisItemKeyListener);
|
||||||
}
|
}
|
||||||
addKeyListener(new KeyListener() {
|
|
||||||
@Override
|
|
||||||
public void keyReleased(KeyEvent e) {
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void keyPressed(KeyEvent e) {
|
|
||||||
if (e.character != 0 && !filterControl.isVisible()) {
|
|
||||||
// enable filter control and send the character there
|
|
||||||
filterControl.setVisible(true);
|
|
||||||
filterControl.setFocus();
|
|
||||||
filterControl.getParent().layout(true);
|
|
||||||
filterControl.getFilterText().setText(e.character + "");
|
|
||||||
filterControl.getFilterText().setSelection(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
setBackground(backgroundColor);
|
setBackground(backgroundColor);
|
||||||
layout(true);
|
layout(true);
|
||||||
}
|
}
|
||||||
|
@ -453,6 +460,7 @@ public class LaunchBarListViewer extends StructuredViewer {
|
||||||
createSash(listComposite);
|
createSash(listComposite);
|
||||||
}
|
}
|
||||||
listComposite.pack(true);
|
listComposite.pack(true);
|
||||||
|
listComposite.layout(true, true);
|
||||||
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
|
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||||
if (elements.length > maxScrollBucket) {
|
if (elements.length > maxScrollBucket) {
|
||||||
Rectangle bounds = listItems[maxScrollBucket].getBounds();
|
Rectangle bounds = listItems[maxScrollBucket].getBounds();
|
||||||
|
|
Loading…
Add table
Reference in a new issue