# File lib/json/editor.rb, line 831
831:       def ask_for_hash_pair(parent)
832:         key_input = type_input = value_input = nil
833: 
834:         dialog = Dialog.new("New (key, value) pair for Hash", nil, nil,
835:           [ Stock::OK, Dialog::RESPONSE_ACCEPT ],
836:           [ Stock::CANCEL, Dialog::RESPONSE_REJECT ]
837:         )
838:         dialog.width_request = 640
839: 
840:         hbox = HBox.new(false, 5)
841:         hbox.pack_start(Label.new("Key:"), false)
842:         hbox.pack_start(key_input = Entry.new)
843:         key_input.text = @key || ''
844:         dialog.vbox.pack_start(hbox, false)
845:         key_input.signal_connect(:activate) do
846:           if parent.any? { |c| c.content == key_input.text }
847:             toplevel.display_status('Key already exists in Hash!')
848:             key_input.text = ''
849:           else
850:             toplevel.display_status('Key has been changed.')
851:           end
852:         end
853: 
854:         hbox = HBox.new(false, 5)
855:         hbox.pack_start(Label.new("Type:"), false)
856:         hbox.pack_start(type_input = ComboBox.new(true))
857:         ALL_TYPES.each { |t| type_input.append_text(t) }
858:         type_input.active = @type || 0
859:         dialog.vbox.pack_start(hbox, false)
860: 
861:         type_input.signal_connect(:changed) do
862:           value_input.editable = false
863:           case ALL_TYPES[type_input.active]
864:           when 'Array', 'Hash'
865:             value_input.text = ''
866:           when 'TrueClass'
867:             value_input.text = 'true'
868:           when 'FalseClass'
869:             value_input.text = 'false'
870:           when 'NilClass'
871:             value_input.text = 'null'
872:           else
873:             value_input.text = ''
874:             value_input.editable = true
875:           end
876:         end
877: 
878:         hbox = HBox.new(false, 5)
879:         hbox.pack_start(Label.new("Value:"), false)
880:         hbox.pack_start(value_input = Entry.new)
881:         value_input.width_chars = 60
882:         value_input.text = @value || ''
883:         dialog.vbox.pack_start(hbox, false)
884: 
885:         dialog.signal_connect('key-press-event''key-press-event', &DEFAULT_DIALOG_KEY_PRESS_HANDLER)
886:         dialog.show_all
887:         self.focus = dialog
888:         dialog.run do |response| 
889:           if response == Dialog::RESPONSE_ACCEPT
890:             @key = key_input.text
891:             type = ALL_TYPES[@type = type_input.active]
892:             content = value_input.text
893:             return @key, type, content
894:           end
895:         end
896:         return
897:       ensure
898:         dialog.destroy
899:       end