patrio2
patrio2

Reputation: 219

onClick eclipse button

I use Eclipse Button

List<Button> aButtons = new ArrayList<Button>();
button = new Button(buttonsComposite, SWT.PUSH);
    button.setText(BTN_TEXT);
    aButtons.add(button);

and i have listener

makeButtonsListen(new Listener() {

        @Override
        public void handleEvent(Event event) {
            handleButtonEvent(event);
        }
    });

private void makeButtonsListen(Listener listener) {
    for (Button button : aButtons) {
        button.addListener(SWT.Selection, listener);
    }
}

My problem is value of event.widget == button change after I let up button. How to do it onClick? I want to when click and hold value is changing. Currently it happens after I let button.

Upvotes: 1

Views: 1930

Answers (1)

Baz
Baz

Reputation: 36884

If you want to listen for the mouse-down event, then add the listener to SWT.MouseDown instead of SWT.Selection:

private void makeButtonsListen(Listener listener) {
    for (Button button : aButtons) {
        button.addListener(SWT.MouseDown, listener);
    }
}

Upvotes: 2

Related Questions