Skip to content

Instantly share code, notes, and snippets.

@danielwestendorf
Created June 17, 2011 17:27
Show Gist options
  • Save danielwestendorf/1031850 to your computer and use it in GitHub Desktop.
Save danielwestendorf/1031850 to your computer and use it in GitHub Desktop.
attr_accessor @main_window, @my_modal_window, @modal_submit_button,
@modal_cancel_button, @modal_value_text_field, @modal_load_default_button
my_modal = SimpleModal.new(@main_window, @my_modal_window) #create the SimpleModal object.
#It expects 2 arguments. The first being the window you're
#going to add the modal to, and the second being the modal
#window you want to add
#now lets add some outlet actions for the modal.
#We don't want to be here... CANCEL!!
my_modal.add_outlet(@modal_cancel_button) do
nil #do nothing, just close the window
end
#how about a submit button?
my_modal.add_outlet(@modal_submit_button) do
value = @modal_value_text_field.stringValue
NSLog "I got the value! #{value}"
end
#let's refresh the default value of the text field, without closing the modal. Passing false keeps the modal open
my_modal.add_outlet(@modal_load_default_button, false) do
@modal_value_text_field.stringValue = "Default value"
end
#finally, let's show the modal
my_modal.show
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment