Disable the Enter key from saving record changes

A place for users and developers of the Xataface to discuss and receive support.

Postby radeski » Tue Jul 24, 2007 12:08 pm

This might be an idiotic question (apologies ;)), but is there a simple way to prevent dataface from saving record changes when in edit mode after the ENTER key is pressed in any given field? I'm using a barcode scanner to enter some of the data: it sends the Enter keystroke after each scan which as a result saves the current dataface record.

Thanks in advance!
Radek
radeski
 
Posts: 12
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Tue Jul 24, 2007 12:16 pm

Ah.. yes.. sounds like a pain. You can try this solution:
http://support.microsoft.com/kb/298498

In order to implement the example given in that kb article, note that you can add javascript event handlers to any fields in the fields.ini file using:

widget:atts:%attname% = ...

so in the kb article example, you would have

widget:atts:onkeydown="testForEnter();"

Let me know if this works for you.

Best regards

Steve
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby radeski » Wed Jul 25, 2007 12:42 pm

Here's the code I'm using to disable the Enter key on _all_ fields:

*****fields.ini

widget:atts:onkeypress="stopEnterKey(event.keyCode);"


*****and javascript:

function stopEnterKey(evt) {
var evt = (evt) ? evt : ((event) ? event : null);
var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
if ((evt.keyCode == 13) && (node.type=="text")) {return false;}

document.onkeypress = stopEnterKey;
}
radeski
 
Posts: 12
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Wed Jul 25, 2007 1:57 pm

Thanks for posting this. If you get a chance, this would make a nice little how-to article. You can post a new how-to document at:
http://framework.weblite.ca/documentation/how-to/createObject?type_name=HelpCenterHowTo

Best regards

Steve
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 23 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved