Z
znndrp
Hi all,
Anyone knows how to use fireEvent to simulate a shit+keypress in a textarea?
thanks,
Anyone knows how to use fireEvent to simulate a shit+keypress in a textarea?
thanks,
Anyone knows how to use fireEvent to simulate a shit+keypress in a
textarea?
znndrp said:Anyone knows how to use fireEvent to simulate a shit+keypress in a
textarea?
Yann-Erwan Perio said:You seem to be targeting IE only, so the solution will be IE only. Note
that triggering a keypress event does not deal with the built-in
pre-event mechanics, i.e. you won't see any letter in your textarea. As
for manipulating the textarea's value, use IE ranges.
Though the idea of triggering events is a good one, I believe that there
usually are better approaches, using handlers and "proxies", but not
knowing what you want to do makes it difficult to determine the best one![]()
Anyone knows how to use fireEvent to simulate a shit+keypress in a
textarea?
znndrp said:I think I don't know myself eitherBut I don't think this is the
solution to my problem.
While I was reading some more on this subject I
also noticed there's method called 'handleEvent()'. What's the
difference between fireEvent and handleEvent?
What's the difference between fireEvent and handleEvent?
or (and this is where handleEvent comes out)
document.addEventListener(
"click",
{handleEvent:function(evt){alert("hello");}},
false
);
The latest isn't well-supported though, the preferred way is to pass
directly the handler as second argument.
Yann-Erwan Perio said:What about telling us the test scenario? This might help!
Michael said:Yann-Erwan Perio wrote:
[snip]or (and this is where handleEvent comes out)
document.addEventListener(
"click",
{handleEvent:function(evt){alert("hello");}},
false
);
The latest isn't well-supported though, the preferred way is to pass
directly the handler as second argument.
Are you certain about that? The handleEvent() method is described in
both level 2 and 3, but it isn't in the ECMAScript bindings for
either. In fact, it states in level 2:
<snip>Object EventListener
This is an ECMAScript function reference. This method has no
return value. The parameter is a Event object.
Michael said:Are you certain about that? The handleEvent() method is described in
both level 2 and 3, but it isn't in the ECMAScript bindings for either.
In fact, it states in level 2:
Object EventListener
This is an ECMAScript function reference. This method has no
return value. The parameter is a Event object.
and more directly in level 3:
EventListener function:
This function has no return value. The parameter is an object
that implements the Event interface.
Michael said:Are you certain about that? The handleEvent() method is described in
both level 2 and 3, but it isn't in the ECMAScript bindings for either.
EventListener function:
This function has no return value. The parameter is an object
that implements the Event interface.
Sorry, I've got this htmledit object which treates a single [enter]
as '</p><p>' and a [shift]+[enter] as '<br>'. My goal is to make this
work the other way round
http://www.interactivetools.com/products/htmlarea/
The function I'm hacking is the 'editor_event()' function in 'editor.js'
....Yann-Erwan Perio said:That's a pretty huge script, however at the function you've pointed out
there's commented code; changing this code a little seems to give the
results you're looking for:
I haven't (nor will) read the whole script so cannot tell whether this
will be safe; only the author could tell![]()
znndrp said:Yes, I've noticed that piece of code, but if I uncommented that, the
UnOrderedList button doesn't work correctly anymore, so that's not an
acceptable solution.
Yann-Erwan Perio said:Then try the following hack instead :
if (ord == 13 && editEvent.type == 'keypress') {
if(editor_obj.tagName.toLowerCase()=="iframe") {
if (
(function(){
var el=editor_obj.contentWindow.document.selection.
createRange().parentElement();
var lc;
while((lc=el.nodeName.toLowerCase())!="body"){
if(lc!="p") break;
el=el.parentNode;
}
return lc=="body";
})()
(ugly, eh?)
znndrp said:Hmm, that seems to work. But I must admit I'm not exactely a JS guru so
you've got to help me a bit here![]()
What are you doing between the
if ((function(){ * })) ??
I also worked out a hack myself, which is a bit larger but appears to
have the same effect.
Yes, but you hold the logic in regards of the buttons pressed, not the
document structure, which could lead to problems if the user doesn't
follow the order button-action; however given the way the editor seems
to work this should be okay I think.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.