diff --git a/motion/ruby_motion_query/stylers/protocols/ui_text_input_traits.rb b/motion/ruby_motion_query/stylers/protocols/ui_text_input_traits.rb index 2714f37..f469939 100644 --- a/motion/ruby_motion_query/stylers/protocols/ui_text_input_traits.rb +++ b/motion/ruby_motion_query/stylers/protocols/ui_text_input_traits.rb @@ -20,7 +20,7 @@ module RubyMotionQuery def keyboard_type=(v) ; view.setKeyboardType(KEYBOARD_TYPES[v] || v) ; end def return_key_type ; view.returnKeyType ; end - def return_key_type=(v) ; view.returnKeyType = v ; end + def return_key_type=(v) ; view.setReturnKeyType(RETURN_KEY_TYPES[v] || v) ; end def secure_text_entry ; view.secureTextEntry ; end def secure_text_entry=(v) ; view.secureTextEntry = v ; end diff --git a/motion/ruby_motion_query/stylers/ui_view_styler.rb b/motion/ruby_motion_query/stylers/ui_view_styler.rb index 98b9153..1907926 100644 --- a/motion/ruby_motion_query/stylers/ui_view_styler.rb +++ b/motion/ruby_motion_query/stylers/ui_view_styler.rb @@ -25,6 +25,20 @@ module RubyMotionQuery alphabet: UIKeyboardTypeASCIICapable } + RETURN_KEY_TYPES = { + default: UIReturnKeyDefault, + go: UIReturnKeyGo, + google: UIReturnKeyGoogle, + join: UIReturnKeyJoin, + next: UIReturnKeyNext, + route: UIReturnKeyRoute, + search: UIReturnKeySearch, + send: UIReturnKeySend, + yahoo: UIReturnKeyYahoo, + done: UIReturnKeyDone, + emergency_call: UIReturnKeyEmergencyCall + } + # When you create a styler, always inherit UIViewStyler class UIViewStyler def initialize(view) diff --git a/spec/stylers/ui_text_field_styler.rb b/spec/stylers/ui_text_field_styler.rb index 344e711..4dcd82c 100644 --- a/spec/stylers/ui_text_field_styler.rb +++ b/spec/stylers/ui_text_field_styler.rb @@ -7,11 +7,16 @@ describe 'stylers/ui_text_field' do st.border_style = UITextBorderStyleRoundedRect st.autocapitalization_type = UITextAutocapitalizationTypeWords st.keyboard_type = UIKeyboardTypeDefault + st.return_key_type = UIReturnKeyNext end def ui_text_field_email(st) st.keyboard_type = :email_address end + + def ui_text_field_google(st) + st.return_key_type = :google + end end before do @@ -32,6 +37,7 @@ describe 'stylers/ui_text_field' do v.borderStyle.should == UITextBorderStyleRoundedRect v.autocapitalizationType.should == UITextAutocapitalizationTypeWords v.keyboardType.should == UIKeyboardTypeDefault + v.returnKeyType.should == UIReturnKeyNext end end @@ -39,4 +45,9 @@ describe 'stylers/ui_text_field' do view = @vc.rmq.append(@view_klass, :ui_text_field_email).get view.keyboardType.should == UIKeyboardTypeEmailAddress end + + it 'should allow setting a return key via symbol' do + view = @vc.rmq.append(@view_klass, :ui_text_field_google).get + view.returnKeyType.should == UIReturnKeyGoogle + end end