Search code examples
eventsswtjruby

In SWT is it possible to distinguish between events caused user interaction vs code?


This example is using JRuby.

For example if I add listener to a Text widget like such:

add_modify_listener do |e|
    options = { event: e, r_value: r_value, source: self, is_interface_object: true, is_storeable: is_storeable? }
    presenter.send r_id, options
end

The listener is called if the user interacts with the widget or I programmatically set the value of the widget text. Is there any way to distinguish between the two potential triggers?

BTW, I know I can listen for different events ie (key events vs modify events), so I am not looking for a workaround, just if its possible to distinguish between the two triggers.


Solution

  • There isn't anything in a SWT Event that tells you where the event came from.

    So, no, you can't tell how the event was generated.