Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » How do you create the 'sunken' look for a selected button?
How do you create the 'sunken' look for a selected button? [message #759505] Mon, 28 November 2011 20:21 Go to next message
John Ormerod is currently offline John OrmerodFriend
Messages: 39
Registered: January 2010
Member
Hello
For example, when you select one of the open perspectives in the IDE, the image of the selected item goes in and stays in. The perspective images behave as though they are a set of image radio-buttons.

I have a need to do something lke that, but as if I had a set of image checkboxes.

I've searched around, but haven't managed to find the right keywords. I think I might be looking for how to modify an (icon?) image to look sunken and normal (and hovered over). If I can get that far, then I assume I can attach mouse listeners to a Label (or drawn image), for mouse-down event, and toggle the 'in' or 'out' appearance.

Regards, John
Re: How do you create the 'sunken' look for a selected button? [message #759931 is a reply to message #759505] Wed, 30 November 2011 15:28 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Hi John,

The perspective chooser buttons are SWT ToolItem controls created with
style SWT.TOGGLE. I don't think I understand how your requirement
differs from this. If you want this same effect on (for instance) a
wizard page or dialog then I would suggest using a similar approach,
even if it means creating several ToolBar controls each containing only
one ToolItem. The "sunken" look is done natively, so I would not
suggest trying to replicate it manually.

HTH,
Grant


On 11/28/2011 3:21 PM, John Ormerod wrote:
> Hello
> For example, when you select one of the open perspectives in the IDE,
> the image of the selected item goes in and stays in. The perspective
> images behave as though they are a set of image radio-buttons.
>
> I have a need to do something lke that, but as if I had a set of image
> checkboxes.
> I've searched around, but haven't managed to find the right keywords. I
> think I might be looking for how to modify an (icon?) image to look
> sunken and normal (and hovered over). If I can get that far, then I
> assume I can attach mouse listeners to a Label (or drawn image), for
> mouse-down event, and toggle the 'in' or 'out' appearance.
>
> Regards, John
>
Re: How do you create the 'sunken' look for a selected button? [message #760916 is a reply to message #759931] Mon, 05 December 2011 15:24 Go to previous message
John Ormerod is currently offline John OrmerodFriend
Messages: 39
Registered: January 2010
Member
Hi Grant
Thanks for your help. The SWT ToolItem rings a bell from a couple of years ago, when I was trying to (mis?)use the underlying toolbar that perspectives uses, in an RCP app.

I don't think I can put a toolbar right in the middle of a Composite.

[edited: The above statement is completely wrong! The parent of a Toolbar is a Composite. So, I have replaced the use of a label descibed below, in my 'button part', with a ToolItem and selection listener. It works fine. Takes up a bit more screen space, but the 'selected' state is clearer. The label solution, does work and could be the answer if you have a lot of buttons and screen space is constrained).]

I've come up with an initial solution. I have 24x24 icon images for the types I want to select from. I've created a row of these 'buttons' using Labels-with-image, and a spacing of 1 pixel. Each 'button' has a mouse-down listener which toggles the image between: 'changed with SWT.GRAY' to produce a disabled look - which gives a reasonable illusion of being depressed, and the default image, as unselected.

Regards, John

[Updated on: Thu, 15 December 2011 11:43]

Report message to a moderator

Previous Topic:Eclipse RCP template with EMF, databinding etc.
Next Topic:I need input on serving web content to the local network from a jetty server inside an RCP.
Goto Forum:
  


Current Time: Fri Apr 26 14:45:31 GMT 2024

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

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

Back to the top