Class: Cosmos::IntegerChooserIntValidator

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

Instance Method Summary collapse

Instance Method Details

#fixup(input) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/cosmos/gui/choosers/integer_chooser.rb', line 16

def fixup(input)
  begin
    value = input.to_i
    if value < bottom()
      # Handle less than bottom
      parent().setText(bottom().to_s)
    elsif value > top()
      # Handle greater than top
      parent().setText(top().to_s)
    elsif input != value.to_s
      # Handle poorly formatted (only known case is float given as starting value)
      parent().setText(value.to_s)
    end
  rescue Exception => err
    # Oh well no fixup
  end
end