0

I am new at Scout and I would like to add Mouse Listener to Button, so I can implement right click on button.

I knew that there is MouseListener object :

MouseListener mouseListener = new MouseListener() {

  @Override
  public void mouseReleased(MouseEvent e) {
    // TODO Auto-generated method stub

  }

  @Override
  public void mousePressed(MouseEvent e) {
    // TODO Auto-generated method stub

  }

  @Override
  public void mouseExited(MouseEvent e) {
    // TODO Auto-generated method stub

  }

  @Override
  public void mouseEntered(MouseEvent e) {
    // TODO Auto-generated method stub

  }

  @Override
  public void mouseClicked(MouseEvent e) {
    // TODO Auto-generated method stub

  }
};

but how to add it to a button?

I find function

addButtonListener(listener);

but mouselistener is not class of button listener (But both are extended from EventListener)

Jmini
  • 9,189
  • 2
  • 55
  • 77
Marko Zadravec
  • 8,298
  • 10
  • 55
  • 97

1 Answers1

1

An important concept behind Eclipse Scout is the separation of UI and GUI. You do not program against a GUI-Library like SWT, but you define forms containing fields. This represents a kind of model of your application. This model is rendered with different technologies (SWT, Swing, and Eclipse RAP to create web application).

The price of this approach is that the model layer does not have as much possibilities as what is offered by each Graphical Library. The model layer focusses on what is necessary for business application (typically form based).

This is why you won’t be able to register a SWT or a Swing MouseListener directly to the Scout model. If you really need to go in this direction, extending the Scout Model might be a good approach. (See this recent example: Scout tables with fixed columns, it concerns the web-ui domain)

The advantage of this approach is that you do not need to rewrite your application when the underlying technologies changes (Graphical Library, Eclipse Platform…). This matters when you are working on applications that have a long lifecycle (like 10+ years).


Duplicate post on the Scout Forum

Jmini
  • 9,189
  • 2
  • 55
  • 77