Last active
July 21, 2017 22:59
-
-
Save AndyObtiva/884c7a204e74a15b91d3d3702926c1ad to your computer and use it in GitHub Desktop.
HelloListSingleSelection Glimmer Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "glimmer" | |
class Person | |
attr_accessor :country, :country_options | |
def initialize | |
self.country_options=["", "Canada", "US", "Mexico"] | |
self.country = "Canada" | |
end | |
def reset_country | |
self.country = "Canada" | |
end | |
end | |
class HelloListSingleSelection | |
include Glimmer | |
def launch | |
person = Person.new | |
shell { | |
composite { | |
list { | |
selection bind(person, :country) | |
} | |
button { | |
text "Reset" | |
on_widget_selected do | |
person.reset_country | |
end | |
} | |
} | |
}.open | |
end | |
end | |
HelloListSingleSelection.new.launch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment