|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
| Grant Gayed
Registered: July 2009
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.
On 11/28/2011 3:21 PM, John Ormerod wrote:
> 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
> 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
| John Ormerod
Registered: January 2010
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.
[Updated on: Thu, 15 December 2011 11:43]
Report message to a moderator
Powered by FUDForum
. Page generated in 0.13300 seconds