Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » How to make a shell behaves like CompletionProposalPopup#fProposalShell
How to make a shell behaves like CompletionProposalPopup#fProposalShell [message #1797684] Mon, 05 November 2018 07:29 Go to next message
Watabe Kichi is currently offline Watabe KichiFriend
Messages: 25
Registered: July 2011
Junior Member
Hello, I'm writing this message from Japan.

I want to make a tooltip shell which is available even in Modal Shell.

In the following SSCCE, tooltipShell fails to grab focus (fails to activate) when clicking.

It seems that [ org.eclipse.jface.text.contentassist.CompletionProposalPopup#fProposalShell ] can grab focus even if SourceViewer is placed in Modal Shell.

Note: fProposalShell is the popup shell which is used when completing.

I read the source code near fProposalShell but I didn't understand how to make it focusable.

Thank you very much in advance.

Here is a single file SSCCE :
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Layout;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

public class ModalTooltipTest2 extends SWTApp {
	public static void main(String[] args) {
		Composite comp = launch(new FillLayout(), SWT.APPLICATION_MODAL | SWT.SHELL_TRIM);
		comp.getShell().setLocation(100,100);
		
		Label l = new Label(comp, SWT.NONE);
		l.setText("TEST");
		
		Shell tooltipShell = new Shell(Display.getCurrent(), SWT.ON_TOP | SWT.TOOL | SWT.RESIZE);
		tooltipShell.setLayout(new FillLayout());
		Text t = new Text(tooltipShell, SWT.BORDER | SWT.MULTI);
		t.setText("TOOLTIP\nTEST\nI WANT TO MAKE THIS TEXT FOCUSED");
		tooltipShell.setLocation(110, 110);
		tooltipShell.pack();
		tooltipShell.open();
		
		loop();
	}
}

class SWTApp {
	private static Display display;
	private static Shell   shell;
	
	protected static Composite launch( Layout layout , int shellStyle) {
		display = new Display();
		shell = new Shell(display, shellStyle);
		
		shell.setLayout(new FillLayout());
		Composite comp = new Composite(shell, SWT.None);
		comp.setLayout( layout );
		
		return comp;
	}
	
	protected static void loop() {
	    loop(true);
	}
	
	protected static void loop(boolean pack) {
		shell.open();
		if(pack) shell.pack();
		while( !shell.isDisposed() ) {
			if( !display.readAndDispatch() ) {
				display.sleep();
			}
		}
		display.dispose();
	}
}

[Updated on: Mon, 05 November 2018 07:39]

Report message to a moderator

Re: How to make a shell behaves like CompletionProposalPopup#fProposalShell [message #1797709 is a reply to message #1797684] Mon, 05 November 2018 14:19 Go to previous messageGo to next message
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 865
Registered: January 2012
Senior Member

I haven't looked at CompletionProposalPopup's code, but it likely works as it parents its Shell to the modal dialog rather than to the display. If you change your tooltip code to:
Shell tooltipShell = new Shell(comp.getShell(), SWT.ON_TOP | SWT.TOOL | SWT.RESIZE);

then it should work.


Eclipse Platform committer. Ask me about Eclipse support, training, and consulting.
Re: How to make a shell behaves like CompletionProposalPopup#fProposalShell [message #1797724 is a reply to message #1797709] Mon, 05 November 2018 16:13 Go to previous message
Watabe Kichi is currently offline Watabe KichiFriend
Messages: 25
Registered: July 2011
Junior Member
Thank you very much. It worked.

But strangely, the following code didn't work.
Shell tooltipShell = new Shell(Display.getCurrent(), SWT.ON_TOP | SWT.TOOL | SWT.RESIZE);
tooltipShell.setParent( comp.getShell() );


Since I am reusing tooltipShell (in modal and non-modal Shell) in my code, It seems I should make a somewhat major change.

Anyway thank you very much.
Previous Topic:JFace Action that supports drop-down AND checkbox
Next Topic:What is the standard way of setting key bindings for SourceViewer
Goto Forum:
  


Current Time: Sat Dec 14 19:40:17 GMT 2019

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

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

Back to the top