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
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 43
Registered: July 2011
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
Eclipse UserFriend
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.
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
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 43
Registered: July 2011
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: Thu Apr 18 18:22:00 GMT 2024

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

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

Back to the top