View Full Version : [FIXED] Touch: slider change event signature is incorrect
jimrising
17 Feb 2012, 7:46 PM
I've been trying to get the value of a slider on change using sencha touch 2.0:
Ext.define('MyApp.view.MySliderField', {
extend: 'MyApp.view.ui.MySliderField',
alias: 'widget.mysliderfield',
initialize: function() {
var me = this;
me.callParent(arguments);
},
onSliderfieldChange: function(slider, value, options) {
console.log(value);
}
});
And all it returns to the console is Ext.apply.create.Class ... how do I get the value of the slider on change?
jimrising
17 Feb 2012, 8:10 PM
the implementation is a bit different:
Ext.define('MyApp.view.MyPanel', {
extend: 'MyApp.view.ui.MyPanel',
initComponent: function() {
var me = this;
me.callParent(arguments);
},
onSliderChange: function(slider, newValue, thumb, options) {
console.log(newValue);
}
});
but this is working fine... just does not seem to work with the sencha touch 2.0 implementation...
aconran
17 Feb 2012, 8:11 PM
Moving this to the bug forum. The signature of the slider change event is (slider, thumb, newValue, oldValue, eOpts).
http://docs.sencha.com/touch/2-0/#!/api/Ext.field.Slider-event-change
The designer is generating the signature as (slider, value, eOpts). This was probably a change in between betas of Sencha Touch that we missed.
jimrising
17 Feb 2012, 8:19 PM
thanks for answering so quickly! :)
is there anything that i can do to make this work while it's being fixed on your side? :)
aconran
18 Feb 2012, 9:39 AM
Put the first line as
var newValue = eOpts;
When we release the fixed signature you'll just delete that first line as newValue will be the appropriate argument.
jimrising
20 Feb 2012, 8:47 AM
not sure where you wanted me to put that line... so I just put it here:
onSliderfieldChange: function(slider, value, options) {
var newValue = eOpts;
console.log(newValue);
}
but this didn't make a lot of sense to me because eOpts isn't being passed in at all?
aconran
20 Feb 2012, 8:56 AM
Sorry.
var newValue = options;
jimrising
20 Feb 2012, 9:06 AM
ok... so the way that 'newValue' works with ext4 ... it returns the new value of the slider.
var newValue = options;
console.log(newValue);
returns the object:
Object
event: "change"
fn: "onSliderfieldChange"
__proto__: Object
__defineGetter__: function __defineGetter__() { [native code] }
__defineSetter__: function __defineSetter__() { [native code] }
__lookupGetter__: function __lookupGetter__() { [native code] }
__lookupSetter__: function __lookupSetter__() { [native code] }
constructor: function Object() { [native code] }
hasOwnProperty: function hasOwnProperty() { [native code] }
isPrototypeOf: function isPrototypeOf() { [native code] }
propertyIsEnumerable: function propertyIsEnumerable() { [native code] }
toLocaleString: function toLocaleString() { [native code] }
toString: function toString() { [native code] }
valueOf: function valueOf() { [native code] }
I'm really just hoping to get the newly set value of the slider control. :) is this found somewhere in this
object? I've looked through it but didn't find any reference to newValue.
aconran
20 Feb 2012, 9:13 AM
The documentation may be incorrect. We will verify this.
Take a look at the arguments variable (if you're not familiar with the arguments object passed to each function in javascript, its a pseudo-array of all the arguments passed to a function, google arguments javascript).
jimrising
20 Feb 2012, 10:23 AM
I think I found it here:
console.log(slider._component._value);
aconran
21 Feb 2012, 8:31 AM
Don't dip into the _component_ property. You could also use slider.getValue()
aconran
2 Mar 2012, 3:25 PM
Fixed in teh next release > 298.
Powered by vBulletin® Version 4.1.5 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.