Qooxdoo delays creating DOM elements until it actually needs them, which
means that the iframe may not exist at the time when you want to set the
event listener. Try something like;
htmlArea.addListenerOnce("appear", function(evt) {
var html_doc = htmlArea.getContentDocument();
[ snip ]
});
Once you're catching events from the iframe, it's probably best not to try
and simulate the qooxdoo event system events can bubble and events like
keyboard events can vary subtly from browser to browser; Qooxdoo's event
system is not trivial or easily modified and you could end up introducing
some hard to find bugs.
In my experience (albeit with TinyMCE, but it's the same principal) the best
way forward is to treat the event handlers on your iframe's document as
completely separate to the "normal" qooxdoo events and if necessary pass
them on as higher level, Qooxdoo events - e.g. if you're trying to detect
whether the user has modified the content, fire a changeModified rather than
passing keyup/down around the system. This lets you cater for browser
differences, which is a big issue with online editors.
John
From: Alexei Vinidiktov <[email protected]>
Reply-To: qooxdoo Development <[email protected]>
Date: Tuesday, 26 February 2013 10:25
To: qooxdoo Development <[email protected]>
Subject: Re: [qooxdoo-devel] changeValue event in htmlArea?
On Mon, Feb 25, 2013 at 11:43 PM, John Spackman <[email protected]>
wrote:
> I've not used HtmlArea for a while but it might worth bearing in mind that it
> is implemented as an iframe and events go to the iframe, not to the main
> window you might have to trap events on the iframe's document body. In
> order for your sample to work, HtmlArea would have to be specifically trapping
> the event inside the iframe and firing a duplicate on the htmlArea object.
How can I add an event listener on the iframe document of HtmlArea?
I've tried the following code, but got the error message "Uncaught
TypeError: Cannot call method 'addEventListener' of null ":
var html_doc = htmlArea.getContentDocument();
html_doc.addEventListener("keypress", function(e) {
alert("key pressed!");
}, this);
And how do I fire duplicate events on the htmlArea object?
Thanks!
--
Alexei Vinidiktov
----------------------------------------------------------------------------
-- Everyone hates slow websites. So do we. Make your web apps faster with
AppDynamics Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb__________________________________________
_____ qooxdoo-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel