-
Notifications
You must be signed in to change notification settings - Fork 723
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to Write User Defined Functions? #116
Comments
Have you looked at the scientific calculator demo? The code examples you can look at are in the calculator.js file |
Hi, No. i'm just looking scientific calculator code. But i have doubt just i need to pass parameter.that parameter just return that values only. i don't need any button event. when i'm pressing entry key i would take that parameter value and do some process in my code. i want to increase the height of the textbox when i'm clicked the textbox of the keyboard. |
Can you be more specific as to what you need then? If the user clicks a button, or presses a key on their keyboard, what parameter gets passed and what ends up in the input? All modern browsers have a resizable textbox (bottom right corner) so you really shouldn't need to change the height, but if you want you can add CSS to increase the size like this: .ui-keyboard-has-focus .ui-keyboard-preview { height: 100px; } |
Hi, This is my code. see the below example; $('#amount_to_pay').keyboard({
layout: 'numberonly',
autoAccept : true,
USERDEFINEDVARIABLE : 'XXXX' // like this i'm declaring variable
}).addTyping();
$('#reference').keyboard({
layout: 'alphanumeric',
USERDEFINEDVARIABLE : 'YYY' // like this i'm declaring variable
}).addTyping();
function process_touchscreen_udf(_param)
{
alert(_param);
//do some code...
} JQUERY.KEYBOARD.JS // added
$.extend($.keyboard.keyaction, {
enter : function(base) {
// accept the content and close the keyboard
base.accept();
// submit the form
// base.$el.closest('form').submit();
// call user defined function
//i'm calling the user defined varaible here. XXX or YYY value
process_touchscreen_udf(USERDEFINEDVARIABLE);
},
}); i'm having a lot of textbox's and textarea's on which i'm going to write use this keyboard layout script.presently these controls are invoking a common userdefined function which is scripted using different conditional statements to recognize the parent control which invoked the function and perform some additional action.so it will be usefull for me if i will be able to add a parameter which will be used to do the same by using the keyboard layout.above code snippet gives you more carification about this .you can see USERDEFINEDVARIABLE which am going to use to pass information from the layout to custom function. Thanks |
I think it would be easier if you added the variable to the textbox (I didn't realize you meant input) itself: <input type="text" placeholder="enter something..." data-myvariable="XXXX"> then when you define the function, just get that data attribute // added
$.extend($.keyboard.keyaction, {
enter : function(base) {
// accept the content and close the keyboard
base.accept();
// submit the form
// base.$el.closest('form').submit();
// call user defined function
//i'm calling the user defined varaible here. XXX or YYY value
process_touchscreen_udf( base.$el.attr('data-myvariable') );
},
}); |
Thanks very much. it's working... |
Hi. I'm facing one more problem. When i'm pressing Enter key i'm invoking my own function. When i'm press Accept Button in the keyboard. i need to invoke my own function same like ENTER Key code. see the below sample: $.extend($.keyboard.keyaction, {
enter : function(base) {
// accept the content and close the keyboard
base.accept();
// call user defined function
process_touchscreen_udf(base.$el.attr('custom_attr_touchscreen'));
},
accept : function(base){
// accept the content and close the keyboard
base.accept();
// call user defined function
process_touchscreen_udf(base.$el.attr('custom_attr_touchscreen'));
}
}); It's working But I'm getting the following error message
keyboard.js // do combo replace
t2 = base.$preview.caret().text.replace(base.regex, function(s, accent, letter){
return (o.combos.hasOwnProperty(accent)) ? o.combos[accent][letter] || s : s;
}); BUT i'm using below code. it's works. $.extend($.keyboard.keyaction, {
enter : function(base) {
// accept the content and close the keyboard
base.accept();
// call user defined function
process_touchscreen_udf(base.$el.attr('custom_attr_touchscreen'));
},
accept : function(base){
base.close(true);
// call user defined function
process_touchscreen_udf(base.$el.attr('custom_attr_touchscreen'));
return false;
}
}); why? |
Hi muruganasm! I just updated the keyboard script to hopefully catch that error. Could you please test it out for me. Thanks. |
Hi. i tried it. but same problem occurs accept : function(base){
// accept the content and close the keyboard
base.accept();
// call user defined function
process_touchscreen_udf(base.$el.attr('custom_attr_touchscreen'));
//return false;
}, but i did small changes in the code. it's working fine. accept : function(base){
// accept the content and close the keyboard
base.accept();
// call user defined function
process_touchscreen_udf(base.$el.attr('custom_attr_touchscreen'));
return false;
} Thanking you very much... |
You're welcome! So can this issue be closed? |
yes... |
Hi,
i need to write custom user defined functions. i need to pass some parameters and when i'm pressing enter key i will take parameter. do some process.
help me...
it's urgent...
The text was updated successfully, but these errors were encountered: