RubyMotion: Find each character entry in UITextField

I am new to RubyMotion for iOS app, but I coded using Objective C.

My requirement is to get the delegate method which should be called for every char type in UITextField.

Objective C: I used "shouldChangeCharactersInRange" for finding the user character entry.

Can you anyone suggest me how to implement this function in RubyMotion for tracking character type in UITextField

Thank you.

Regards.

Answers


First, when you create the text field, make sure you set the delegate to the same View Controller class it's in:

textField = UITextField.alloc.initWithFrame([[10,200],[300,40]])
textField.delegate = self

Then add this method to that class:

def textField(textField, shouldChangeCharactersInRange:range, replacementString:string)
  # return true or false based on whether you want to allow the replacement
  true
end

I like the BubbleWrap syntax:

textField.when(UIControlEventEditingChanged) do
  # something
end

Need Your Help

How can I get syntax highlighting for a .cu file in Visual Studio?

visual-studio visual-studio-2008 cuda syntax-highlighting

I am studying CUDA based on the Visual Studio 2008. Could you please tell me how to make syntax highlighting appear in a .cu file?