Did you press the SWT soft key?

I am trying to set the SWT button to the “pressed” state programmatically. Is it possible somehow?

Update:
What I'm trying to achieve is to draw a button in the selected state on the image.

Image buttonimg_mouseover = new Image(getDisplay(), 100, 100); Button button = new Button(parent.parent, SWT.PUSH); button.setAlignment(SWT.CENTER); button.setImage(arrowimg); button.setSize(100, 100); button.setSelection(true); // doesn't work GC gcbutton = new GC(buttonimg_mouseover); //draw an image of the button button.print(gcbutton); 
+4
source share
1 answer

You can do it with the following snippet

 Button myButton = new Button(parent, SWT.TOGGLE); myButton.setSelection(true); 

However, this will only work with CHECK , RADIO or TOGGLE types.

See Javadoc Button#setSelection(boolean) .

+8
source

Source: https://habr.com/ru/post/1445044/


All Articles