client/js/controls/button/button.coffee in rsence-pre-3.0.0.8 vs client/js/controls/button/button.coffee in rsence-pre-3.0.0.9
- old
+ new
@@ -6,11 +6,12 @@
HButton = HControl.extend
componentName: 'button'
optimizeWidthOnRefresh: true
controlDefaults: HControlDefaults.extend
- defaultKeyClick: false
+ defaultKeyClick: false # use defaultResponder instead; it's a better name
+ defaultResponder: false
pack: false
defaultEvents:
click: true
@@ -25,23 +26,31 @@
else
@setStyleOfPart('label',_name,_value)
@
defaultKey: ->
- if @options.defaultKeyClick
+ if @enabled and ( @options.defaultKeyClick or @options.defaultResponder )
+ if @options.defaultKeyClick and !@isProduction
+ console.warn("defaultKeyClick is deprecated; use defaultResponder instead (sorry)")
+ @setCSSClass('clickeffect')
+ @timeouts.push( setTimeout( =>
+ @unsetCSSClass('clickeffect')
+ , 200 ) )
@click()
return false
null
click: ->
console.log('no click action defined in HButton') if !@isProduction
refresh: ->
@base()
- if @options.defaultKeyClick
- @toggleCSSClass(@elemId,'action',true)
+ if @options.defaultKeyClick or @options.defaultResponder
+ if @options.defaultKeyClick and !@isProduction
+ console.warn("defaultKeyClick is deprecated; use defaultResponder instead (sorry)")
+ @setCSSClass('action')
else
- @toggleCSSClass(@elemId,'action',false)
+ @unsetCSSClass('action')
labelPadding: 0
optimizeWidth: ->
_labelWidth = @stringWidth(@label,null,@markupElemIds.label)
_labelWidth += @labelPadding+Math.floor(@rect.height*0.6)