Skip to end of metadata
Go to start of metadata

listen/2 (i,i)

This predicate is part of the Prova extension for Swing. It adds a listener to various Swing events on the specified UI target. The created listener then generates Prova events that can be intercepted with usual Prova reactions. The reactions are executed on the specially designated Swing event thread, not on the usual task or async thread pools. The unlisten built-in predicate removes the appropriate listener.

The built-in accepts the following parameters:

  1. the mode - either action, mouse, change or motion;
  2. the target - either a java.swing.AbstractButton for action or mouse events, or a java.awt.Component for _change or motion events.

The format of the messages generated by the listener is the same as if it was generated with the following sendMsg statements. The class ProvaSwingAdaptor is responsible for this mapping.

You can study the standalone example swing_rx.prova that demonstrates how strings of UI actions (in particular, mouse gestures) can be detected as event patterns using Swing events accepted as Prova messages. It follows closely

Here are some critical fragments. First register the listener.

Now detect mouse gestures mapping them to event patterns.

Labels: