开发者

Preventing SWT Browser Elements from Receiving Mouse Clicks

开发者 https://www.devze.com 2023-03-11 19:47 出处:网络
I\'m working with the eclipse SWT toolkit, and I\'m trying to use it to create a browser window that only passes mouse clicks to the underlying document conditionally (I want to stop Flash and Javascr

I'm working with the eclipse SWT toolkit, and I'm trying to use it to create a browser window that only passes mouse clicks to the underlying document conditionally (I want to stop Flash and Javascript in the page from getting clicks). I'd like some way of doing one of:

  • Examining mouse e开发者_高级运维vents as they come in, and only passing them on to other listeners based on conditions I specify.
  • Removing all listeners from a window, and only putting back the ones I want.

Are either of these possible?


Browser, like other SWT components, have addMouseListener method. So you could implement your own listener a pass only which one you want.

see javadoc of browser

Edit

According to your request, there could be two possible ways to do it.

First, you could use listening of events from JavaScript in browser (there is no way to avoid JavaScript if you work with html pages). If you know that you will have Mozilla browser render core (you have to install XUL Runner), you could use JavaXPCOM, but that's big unknown for me.

snippet - listen for DOM mousedown events with javascript

Second, you can call Java functions from JavaScript (again, handle onclick event, and then decide on Java, if you don't want to use JavaScript for it).

snippet - call Java from JavaScript

But frankly both ways are more ugly-er that proposed way by pure JavaScript.

0

精彩评论

暂无评论...
验证码 换一张
取 消