prithvirulzzz
BAN USER- 0 Answers Java(SWT) - Control key + M on the keyboard triggers double-click functionality on Tree Items in SWT
I have a double-click functionality for the tree viewers wherein the tree items expand\collapse when I double-click on them, but when I press CTRL+M on the keyboard even then the tree items expand\collapse, My code for double-clicking tree items is as follows:
- prithvirulzzz May 15, 2014
private class DoubleClickListener implements IDoubleClickListener
{
@Override
public void doubleClick(final DoubleClickEvent event)
{
final IStructuredSelection selection = (IStructuredSelection)event.getSelection();
if (selection == null || selection.isEmpty())
return;
final Object sel = selection.getFirstElement();
final ITreeContentProvider provider = (ITreeContentProvider)treeViewer.getContentProvider();
if (!provider.hasChildren(sel))
return;
if (treeViewer.getExpandedState(sel))
treeViewer.collapseToLevel(sel, AbstractTreeViewer.ALL_LEVELS);
else
treeViewer.expandToLevel(sel, 1);
}
}
I can supress CTRL+M through adding key listener but my question is as follows :
This behavior (CTRL+m expanding tree items) only happens When I use the IDoubleClickListener interface and override the method doubleClick(), but the same behavior (CTRL+m expanding tree items) does not happen when I use : addMouseListener(new MouseListener()) and override the method : mouseDoubleClick(). Is the behavior (CTRL+m) expanding tree items related to IDoubleClickListener interface(If so what is the reason) or is this problem generic? I feel it should not be related to IDoubleClickListener, Can someone please tell me why is there a difference in using these two logic?| Flag | PURGE - 1 Answer Java Swt Tooltip
Hello all, I need your help on this
- prithvirulzzz March 15, 2014
I have a swt tooltip being set on a label.. The tooltip method will be called setTooltip(message) will be called from a different class and the setMessage(message) will be set in the class where tooltip object will be created.. Right now Im checking for null or empty condition before setting the tooltip message otherwise it would throw IllegalArgumentException.. so my code is as such
public void setTooltip(String message) {
if (message != null && !message.isEmpty()) {
tooltip.setMessage(message);
label.addMouseTrackListener(mouseTrackListener);
iconLabel.addMouseTrackListener(mouseTrackListener);
} else {
label.removeMouseTrackListener(mouseTrackListener);
iconLabel.removeMouseTrackListener(mouseTrackListener);
}
}
I need an option in the else condition because the control goes to that line even If tooltip has not been associated with the listener.| Flag | PURGE - 0 Answers Java SWT Tooltips
0 down vote favorite
- prithvirulzzz February 26, 2014
Please help me out on this, I have been breakin my head over this for weeks together.
I have a Class called InformationArea.java which displays an information area to the user. There a label called "enter a unique name" in the infomation area(basically an import dialog window). When I hover the mouse over that label there is a empty tooltip being displayed. I would want to remove that tooltip(I mean I dont want it to be shown). I can easily say tooltip.setVisibility(false) but I should not change the code inside the MouseTrackListener Anonymous class. I need to use a toltip property pr anythin else so that when I extend this class I need to have an option to easily set the visibility of this tooltip if needed or disable it if not needed.
Here is my Code snippet (JAVA SWT)
tooltip = new ToolTip(parent.getShell(), SWT.NONE);
MouseTrackListener mouseTrackListener = new MouseTrackListener() {
@Override
public void mouseEnter(MouseEvent e) {
if (text != null && !text.isEmpty()) {
tooltip.setLocation(Display.getCurrent().getCursorLocation().x,
Display.getCurrent().getCursorLocation().y + TOOLTIP_OFFSET_Y);
tooltip.setVisible(true);
}
}
@Override
public void mouseExit(MouseEvent e) {
if (text != null && !text.isEmpty()) {
tooltip.setVisible(false);
}
}
@Override
public void mouseHover(MouseEvent e) {
{
}};
label.addMouseTrackListener(mouseTrackListener);
iconLabel.addMouseTrackListener(mouseTrackListener);
I want an option such that the tooltip can be built or destroyed when ever needed in the derived class without changin the code in the MouseTrackListener| Flag | PURGE