Class: Cosmos::FloatChooserDoubleValidator

Inherits:
Qt::DoubleValidator
  • Object
show all
Defined in:
lib/cosmos/gui/choosers/float_chooser.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ FloatChooserDoubleValidator

Returns a new instance of FloatChooserDoubleValidator.



17
18
19
# File 'lib/cosmos/gui/choosers/float_chooser.rb', line 17

def initialize(*args)
  super(*args)
end

Instance Method Details

#fixup(input) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/cosmos/gui/choosers/float_chooser.rb', line 21

def fixup(input)
  begin
    value = input.to_f
    if value < bottom()
      # Handle less than bottom
      parent().setText(bottom().to_s)
    elsif value > top()
      # Handle greater than top
      parent().setText(top().to_s)
    end
  rescue Exception => err
    # Oh well no fixup
  end
end