PDA

View Full Version : Mouse on Hold to increment & Decrements the numbers like xtype:NumberField



praveen585
27 May 2016, 5:01 AM
Hi All,


I have my text field with segmented buttons with + and - for numbers increment and decrements like below image
54583
Logic to Increment & Decrements


items: [{
text: '+',
handler: function() {
var temValue =parseInt( Ext.getCmp('mytempId').getValue());
if(isNaN(temValue)){
Ext.getCmp('mytempId').setValue(0);
}else{
Ext.getCmp('mytempId').setValue(temValue+1);
}
}
},{
text: '-',
handler: function() {
var temValue =parseInt( Ext.getCmp('mytempId').getValue());
if(isNaN(temValue)){
Ext.getCmp('mytempId').setValue(0);
}else{
Ext.getCmp('mytempId').setValue(temValue-1);
}
}
}]




Problem is I can Increment value only on click but I need on mouse hold to increase the value.
Can some help to solve this Issue.


Thanks in advance

jdkhamba
27 May 2016, 5:17 AM
Why not just use a numberfield instead? it comes with a built in spinner which on mouse hold increments or decrements the value. Also, if you focus on the field and scroll your mouse it does the same in case you don't want to see the spinner.

http://docs.sencha.com/extjs/4.2.0/#!/api/Ext.form.field.Number

praveen585
27 May 2016, 5:20 AM
I am going to use this in tab where number field spinners are difficult to use.

jdkhamba
27 May 2016, 5:21 AM
I don't understand. Why can't numberfields be used in a tab panel?