Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Tooltips for disabled Buttons
Tooltips for disabled Buttons [message #733652] Wed, 05 October 2011 06:04 Go to next message
T. Wilhelm is currently offline T. Wilhelm
Messages: 7
Registered: December 2010
Junior Member
Hi all,

i want to show a tooltip for a disabled button (because i want to display why it´s disabled), is there any solution? I already searched in this forum, but the answer was that it is the expected behaviour on windows that disabled buttons cannot show tooltips Sad Does anyone have a good workaround?

Thanks alot
Thomas
Re: Tooltips for disabled Buttons [message #734399 is a reply to message #733652] Fri, 07 October 2011 11:40 Go to previous message
Grant Gayed is currently offline Grant Gayed
Messages: 2149
Registered: July 2009
Senior Member
Hi Thomas,

(verified on win32) The following snippet demonstrates getting a
MouseHover event. From this you should be able to show a custom tooltip
(either a ToolTip instance or an emulated tooltip like in
http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet125.java
).

public static void main(String[] args) {
final Display display = new Display();
Shell shell = new Shell(display);
shell.setBounds(10,10,200,200);
Composite composite = new Composite(shell, SWT.NONE);
composite.setBounds(10,10,90,50);
Button button = new Button(composite, SWT.PUSH);
button.setBounds(0,0,90,50);
button.setText("button");
composite.addListener(SWT.MouseHover, new Listener() {
public void handleEvent(Event event) {
System.out.println("called");
// show a custom tooltip here
}
});
button.setEnabled(false);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}

Grant


On 10/5/2011 6:04 AM, T. Wilhelm wrote:
> Hi all,
>
> i want to show a tooltip for a disabled button (because i want to
> display why it´s disabled), is there any solution? I already searched in
> this forum, but the answer was that it is the expected behaviour on
> windows that disabled buttons cannot show tooltips :( Does anyone have a
> good workaround?
>
> Thanks alot
> Thomas
Previous Topic:OSX: HotKeys not working
Next Topic:MeasureItem event listener problem on Windows 7
Goto Forum:
  


Current Time: Tue Sep 02 03:00:50 EDT 2014

Powered by FUDForum. Page generated in 0.12914 seconds