[mochikit] Re: Trapping Safari's ENTER key

2006-08-30 Thread chris feldmann

On 8/29/06, hartshorne <[EMAIL PROTECTED]> wrote:
>
> It seems you can't cancel onkeydown events with Safari. You can cancel
> onkeypress events, but MochiKit doesn't return key().string for special
> keys in a keypress event. To prevent form submissions, just do
> something like this:
>
> connect('someForm', 'onsubmit', function(e) { e.stop(); });
>

You are indeed a tenacious investigator. But indeed your solution is
the one I eventually came to lo those 27 days ago when this thread
died.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to mochikit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~--~~~~--~~--~--~---



[mochikit] Re: Trapping Safari's ENTER key

2006-08-29 Thread hartshorne

It seems you can't cancel onkeydown events with Safari. You can cancel
onkeypress events, but MochiKit doesn't return key().string for special
keys in a keypress event. To prevent form submissions, just do
something like this:

connect('someForm', 'onsubmit', function(e) { e.stop(); });


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to mochikit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~--~~~~--~~--~--~---



[mochikit] Re: Trapping Safari's ENTER key

2006-08-02 Thread Beau Hartshorne

On 27-Jul-06, at 12:37 PM, Alexandre A. Falcão wrote:

> I wrote "Looks like"... So that is just my opinion. I didn't found  
> a way to cancel keyboard events propagation on safari... Even  
> mdonoughe's exemple didn't work in my script. I didn't look at  
> safari's bugzilla for a  refer to this problem. But there's a lot  
> of etries at the safari's maillist: http://search.lists.apple.com/? 
> q=StopPropagation&cmd=Search%21
>
> But note that in new yahoo mail beta they DID IT!! I can't find how  
> they stop the event propagation on events onkeydown, press or up.  
> (see maillist navigation using KEY_UP and KEY_DOWN, keyboard arrow  
> keys) but I'd love to know how :D

Alright, I'll look into this. If you find out anything about this,  
please add a comment to the ticket:
http://trac.mochikit.com/ticket/154


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to mochikit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~--~~~~--~~--~--~---



[mochikit] Re: Trapping Safari's ENTER key

2006-07-27 Thread KevinDamm

I know this doesn't directly address the problem, but couldn't you
return false in the onSubmit handler for the form to make it so hitting
ENTER doesn't send the form off?  You could then have an additional
control or widget that sends the form in an appropriate way.

 - Kevin


chris feldmann wrote:
> Hi mochinauts.
> I am trying to disable form submission on enter keydown. This snippet
> works on every platform except safai, which even does the visual
> "submit press" animation cue and then submits. Is there some secret
> sauce for safari's enter key?
>
> connect( window, "onload", function(){
> connect( document, "onkeydown", function( e ){
> e.stop();
> var key = e.key();
> for( p in key ){
> logDebug( p + " : " + key[p] );
> }
> if( key.code == 13 || key.code == 3 ){
>
> return false;
> 
> }
> } );


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to mochikit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~--~~~~--~~--~--~---



[mochikit] Re: Trapping Safari's ENTER key

2006-07-27 Thread Alexandre A. Falcão

Beau,

I wrote "Looks like"... So that is just my opinion. I didn't found a way 
to cancel keyboard events propagation on safari... Even mdonoughe's 
exemple didn't work in my script. I didn't look at safari's bugzilla for 
a  refer to this problem. But there's a lot of etries at the safari's 
maillist: http://search.lists.apple.com/?q=StopPropagation&cmd=Search%21

But note that in new yahoo mail beta they DID IT!! I can't find how they 
stop the event propagation on events onkeydown, press or up. (see 
maillist navigation using KEY_UP and KEY_DOWN, keyboard arrow keys) but 
I'd love to know how :D

Pigmeu

Beau Hartshorne escreveu:
> On 26-Jul-06, at 11:04 PM, chris feldmann wrote:
>
>   
>> Pigmeu, I thank you for your report.
>>
>> Beau, do you concur?
>> 
>
> I'd like to check Safari's bugzilla to see if this has been reported  
> there. If it is, I'd like to refer to it from MochiKit's docs. If  
> it's not, I'll need to make a reduced test case and then refer to it  
> from MochiKit's docs. Has anyone found this in bugzilla?
>
> Beau
>
>
> >
>   


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to mochikit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~--~~~~--~~--~--~---



[mochikit] Re: Trapping Safari's ENTER key

2006-07-27 Thread Beau Hartshorne

On 26-Jul-06, at 11:04 PM, chris feldmann wrote:

> Pigmeu, I thank you for your report.
>
> Beau, do you concur?

I'd like to check Safari's bugzilla to see if this has been reported  
there. If it is, I'd like to refer to it from MochiKit's docs. If  
it's not, I'll need to make a reduced test case and then refer to it  
from MochiKit's docs. Has anyone found this in bugzilla?

Beau


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to mochikit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~--~~~~--~~--~--~---



[mochikit] Re: Trapping Safari's ENTER key

2006-07-27 Thread mdonoughe

chris feldmann wrote:
> Hi mochinauts.
> I am trying to disable form submission on enter keydown. This snippet
> works on every platform except safai, which even does the visual
> "submit press" animation cue and then submits. Is there some secret
> sauce for safari's enter key?
>
> connect( window, "onload", function(){
> connect( document, "onkeydown", function( e ){
> e.stop();
> var key = e.key();
> for( p in key ){
> logDebug( p + " : " + key[p] );
> }
> if( key.code == 13 || key.code == 3 ){
>
> return false;
>
> }
> } );

I have an application that makes use of the return key and works fine
in Safari and Firefox. I use the following:

var sendkeyspecial = 0;

var initpage = function () {
MochiKit.Signal.connect(document, "onkeypress", this, "keypress");
MochiKit.Signal.connect(document, "onkeydown", this, "keydown");
MochiKit.Signal.connect(document, "onkeyup", this, "keyup");
};

var isspecialkey = function(e) {
if(e == 13 || e == 8)
return 1;
}

this.keypress = function(e) {
  if(e.modifier()['meta'])
return;
  var code = e.key().code;
  if(code == 0)
code = sendkeyspecial;
if(isspecialkey(code) == 1) {
if(code == 13) { //return
e.stop();
return;
}
if(code == 8) { //backspace
e.stop();
return;
}
}
e.stop();
}

this.keydown = function(e) {
sendkeyspecial = e.key().code;
}

this.keyup = function(e) {
sendkeyspecial = 0;
}

MochiKit.DOM.addLoadEvent(initpage);


This catches all keypresses that don't involve the meta(command) key. I
would probably add special handling for the control key if I was doing
serious development, but this is more of a toy script on my Mac for
now. The sendkeyspecial thing is used to get key repeating to work
properly for special keys in some browsers. 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to mochikit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~--~~~~--~~--~--~---



[mochikit] Re: Trapping Safari's ENTER key

2006-07-26 Thread chris feldmann
On 7/25/06, "Alexandre A. Falcão" <[EMAIL PROTECTED]> wrote:
> Hi guys,
>
> I had the same problem when mading keyboard shortcuts to a scroll list...
>
> Looks like safari call the events and you can "see" what's going on, but
> it doesn't allow you to stop propagation on keyboard events. So, it will
> ever run the default action for a keyboard event. (like a form submit).
>
>
> Pigmeu
>

Pigmeu, I thank you for your report.

Beau, do you concur?

-chris

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to mochikit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~--~~~~--~~--~--~---



[mochikit] Re: Trapping Safari's ENTER key

2006-07-25 Thread Alexandre A. Falcão

Hi guys,

I had the same problem when mading keyboard shortcuts to a scroll list...

Looks like safari call the events and you can "see" what's going on, but 
it doesn't allow you to stop propagation on keyboard events. So, it will 
ever run the default action for a keyboard event. (like a form submit).


Pigmeu


chris feldmann escreveu:
>> Hi Chris,
>>
>> Try looking for key.string == 'KEY_ENTER'. If that doesn't work,
>> please post a full example for me to play with.
>>
>> Thanks,
>> Beau
>>
>> 
> Hi Beau.
> Thanks for your reply and also for your work on Signal.js which is one
> slick chunk of code. I made this test script for my server-side guy to
> test on Safari for me because I don't have my powerbook. He reports
> that this (which is supposed to essentially disable the entire
> keyboard) STILL submits on enter keydown on safari.:
> 
> MochiKit.Signal.VERSION
> 1.4
> 
> 
> 
>  src="http://axlotl.dyndns.org/mochikit/packed/MochiKit/MochiKit.js";>
> 
> connect( window, "onload", function(){
> connect( document, "onkeydown", function( e ){
> e.stop();
> var key = e.key();
> for( p in key ){
> logDebug( p + " : " + key[p] );
> }
> logDebug("\n");
> if( key.code == 13 || key.code == 3 || key.string
> == 'KEY_ENTER' ){
>
> return false;
>
> }
> } );
> MochiKit.LoggingPane.createLoggingPane( true );
>
> });
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
>
> >
>   


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to mochikit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~--~~~~--~~--~--~---



[mochikit] Re: Trapping Safari's ENTER key

2006-07-25 Thread chris feldmann

> Hi Chris,
>
> Try looking for key.string == 'KEY_ENTER'. If that doesn't work,
> please post a full example for me to play with.
>
> Thanks,
> Beau
>
Hi Beau.
Thanks for your reply and also for your work on Signal.js which is one
slick chunk of code. I made this test script for my server-side guy to
test on Safari for me because I don't have my powerbook. He reports
that this (which is supposed to essentially disable the entire
keyboard) STILL submits on enter keydown on safari.:

MochiKit.Signal.VERSION
1.4



http://axlotl.dyndns.org/mochikit/packed/MochiKit/MochiKit.js";>

connect( window, "onload", function(){
connect( document, "onkeydown", function( e ){
e.stop();
var key = e.key();
for( p in key ){
logDebug( p + " : " + key[p] );
}
logDebug("\n");
if( key.code == 13 || key.code == 3 || key.string
== 'KEY_ENTER' ){

return false;

}
} );
MochiKit.LoggingPane.createLoggingPane( true );

});











--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to mochikit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~--~~~~--~~--~--~---



[mochikit] Re: Trapping Safari's ENTER key

2006-07-25 Thread Beau Hartshorne

On 25-Jul-06, at 10:35 AM, chris feldmann wrote:

> I am trying to disable form submission on enter keydown. This snippet
> works on every platform except safai, which even does the visual
> "submit press" animation cue and then submits. Is there some secret
> sauce for safari's enter key?
>
> connect( window, "onload", function(){
> connect( document, "onkeydown", function( e ){
> e.stop();
> var key = e.key();
> for( p in key ){
> logDebug( p + " : " + key[p] );
> }
> if( key.code == 13 || key.code == 3 ){
>
> return false;
>
> }
> } );

Hi Chris,

Try looking for key.string == 'KEY_ENTER'. If that doesn't work,  
please post a full example for me to play with.

Thanks,
Beau

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to mochikit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~--~~~~--~~--~--~---