Menu

Receiving focus events from JHTMLEditor

Help
2011-11-10
2015-04-11
  • Lynn Thompson

    Lynn Thompson - 2011-11-10

    Hi, thank you so much for this great body of work. I have a question about
    using the JHTMLEditor in a Swing desktop application. Should it still be
    possible to register a FocusListener to receive a focusLost event? I'm not
    getting any events through. And I feel like I read something about that...
    somewhere... and I'm searching and searching and can't find what I read. Any
    hints to push me in the right direction??? Thank you!

     
  • Lynn Thompson

    Lynn Thompson - 2011-11-14

    When I run the InputEventsExample, I get mouseEvents just fine. But if I try
    to add a focus listener to the native component I get no events. I'm very new
    to this, and apologize for the newbieness of this. Should I just try to find a
    different way to do what I need to do? Thank you!

     
  • Christopher Deckers

    Hi,

    Focus events originating from the native component are not reliable... It is a
    known SWT issue:
    https://bugs.eclipse.org/bugs/show_bug.cgi?id=84532

    I would suggest you vote for this bug. But in the meantime, you would have to
    find a way around.

    Hope this helps,
    -Christopher

     
  • Pete Brower

    Pete Brower - 2015-04-07

    Hi Christopher. I'm running into a problem also with lack of focus events. I need to know when the HTML Editor has been given the focus and when it has lost it. I did look at the SWT bug report you mentioned. There is what they call a simple workaround attached to that bug report. The problem is that the simple workaround seems to be attaching an activate and deactivate listener to the SWT browser widget. From the DJ Project API I can't see how to gain access to the low level SWT browser to attach the listeners. Is there a way to do this? Or have you added the workaround code to a newer version of the DJ Project web browser wrapper so it can generate the focus events?

     

    Last edit: Pete Brower 2015-04-07
  • Christopher Deckers

    Hi Pete,

    I tried that workaround and it does not seem to work in our case. It seems the activate event happens when a Control becomes active within a Shell. In our case, the browser is embedded in a Shell, and thus is the only control that can be activated.
    When I load a web browser with the Google page, the focus goes into the search field, but I don't get the Activate event. When I click in the Browser, I get that event, but giving focus to a Swing component does not trigger the deactivate event. Thus, it seems it is not a suitable replacement for missing focus events.

    Hope this helps,
    -Christopher

     

Log in to post a comment.