client/js/controls/numerictextcontrol/numerictextcontrol.coffee in rsence-pre-3.0.0.9 vs client/js/controls/numerictextcontrol/numerictextcontrol.coffee in rsence-pre-3.0.0.10
- old
+ new
@@ -9,11 +9,11 @@
defaultEvents:
mouseWheel: true
contextMenu: true
keyDown: true
- textEnter: false
+ textEnter: true
click: true
contextMenu: true
controlDefaults: HTextControl.prototype.controlDefaults.extend
numberIncrement: 1
@@ -55,14 +55,19 @@
_value = Math.round(_value*_decPlaces)/_decPlaces
else
_value = parseInt( _value, 10 )
if isNaN( _value )
_value = @value
+ @setValid(false)
if _value > @maxValue
_value = @maxValue
+ @setValid(false)
else if _value < @minValue
+ @setValid(false)
_value = @minValue
+ else
+ @setValid(true)
_value
fieldToValue: (_unFilteredValue)->
_value = ''
for _chr, i in _unFilteredValue.split('')
@@ -93,13 +98,11 @@
## Extends the validateText method to ensure the
## input is a number.
###
# validateText: (_value)-> _value
- _extraLabelRight: 0
drawSubviews: ->
- @base()
@setStyleOfPart('value','textAlign','right')
if @options.withStepper
this._extraLabelRight += 14
@setStyleOfPart('label','right',this._extraLabelRight+'px')
_top = Math.round((@rect.height-22)/2)
@@ -114,18 +117,8 @@
maxValue: @maxValue
stepSize: @options.numberIncrement
enabled: @enabled
)
@stepper.bringToFront()
- if @options.unit
- _unitRect = [null,null,4,@rect.height,4,0]
- @unitSuffix = HLabel.new(_unitRect,@,
- pack: true
- label: @options.unit
- style:
- lineHeight: @rect.height+'px'
- verticalAlign: 'middle'
- )
- @_extraLabelRight += @unitSuffix.rect.width
- @setStyleOfPart('label','right',this._extraLabelRight+'px')
+ @drawUnit()
HNumberField = HNumericTextControl