mirror of
https://github.com/zhigang1992/rmq.git
synced 2026-04-30 05:35:42 +08:00
Allos a user to set keyboard_type with symbols.
This commit is contained in:
@@ -17,7 +17,7 @@ module RubyMotionQuery
|
||||
def keyboard_appearance=(v) ; view.keyboardAppearance = v ; end
|
||||
|
||||
def keyboard_type ; view.keyboardType ; end
|
||||
def keyboard_type=(v) ; view.keyboardType = v ; end
|
||||
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
|
||||
|
||||
@@ -9,6 +9,22 @@ module RubyMotionQuery
|
||||
natural: NSTextAlignmentNatural
|
||||
}
|
||||
|
||||
KEYBOARD_TYPES = {
|
||||
default: UIKeyboardTypeDefault,
|
||||
ascii: UIKeyboardTypeASCIICapable,
|
||||
numbers_punctuation: UIKeyboardTypeNumbersAndPunctuation,
|
||||
url: UIKeyboardTypeURL,
|
||||
number_pad: UIKeyboardTypeNumberPad,
|
||||
phone_pad: UIKeyboardTypePhonePad,
|
||||
name_phone_pad: UIKeyboardTypeNamePhonePad,
|
||||
email_address: UIKeyboardTypeEmailAddress,
|
||||
email: UIKeyboardTypeEmailAddress, # Duplicate to help developers
|
||||
decimal_pad: UIKeyboardTypeDecimalPad,
|
||||
twitter: UIKeyboardTypeTwitter,
|
||||
web_search: UIKeyboardTypeWebSearch,
|
||||
alphabet: UIKeyboardTypeASCIICapable
|
||||
}
|
||||
|
||||
# When you create a styler, always inherit UIViewStyler
|
||||
class UIViewStyler
|
||||
def initialize(view)
|
||||
|
||||
@@ -6,6 +6,11 @@ describe 'stylers/ui_text_field' do
|
||||
st.placeholder = "placeholder"
|
||||
st.border_style = UITextBorderStyleRoundedRect
|
||||
st.autocapitalization_type = UITextAutocapitalizationTypeWords
|
||||
st.keyboard_type = UIKeyboardTypeDefault
|
||||
end
|
||||
|
||||
def ui_text_field_email(st)
|
||||
st.keyboard_type = :email_address
|
||||
end
|
||||
end
|
||||
|
||||
@@ -29,4 +34,9 @@ describe 'stylers/ui_text_field' do
|
||||
v.keyboardType.should == UIKeyboardTypeDefault
|
||||
end
|
||||
end
|
||||
|
||||
it 'should allow setting a keyboard type via symbol' do
|
||||
view = @vc.rmq.append(@view_klass, :ui_text_field_email).get
|
||||
view.keyboardType.should == UIKeyboardTypeEmailAddress
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user