So I’m working on a ui with the ui module and the objc_util module. I needed to use the objc_util to do some user QOL improvements with the TextViews. This got me on wanting to continue improvements, and I’ve added a UIToolbar to the keyboard to allow the user to end editing the TextView with a UIBarButtonItem. But the problem is I also want to add another UIBarButtonItem that will clear all the text in the TextView, but I’m having trouble making this happen. There is no method in the TextView to just clear the text, and when init-ing the button to target the TextView and assigning the action to setText of the TextView I can’t figure out how to pass a empty string parameter. Here's an example of the gist of my problem:
import ui
from objc_util import *
view=ui.View()
textview=ui.TextView()
textview.text="hello" #make text to see if the button works
tvobj=ObjCInstance(textview)
#tried passing below as argument in button action
text=ObjCClass("NSMutableString").alloc().initWithString_('')
#below creates the button and assigns the target and action
#can't figure out how to pass argument as well.
#tried saying "setText:", 'setText:@""','setText=text'
btn=ObjCClass('UIBarButtonItem').alloc().initWithBarButtonSystemItem_target_action_(13,textview,'???')
#the 13 is just the refresh button
#below finishes setting up the view and adding the button to the
#keyboard toolbar
bar=ObjCClass('UIToolbar').alloc().init()
bar.sizeToFit()
keyboard=ObjCClass('UIKeyboard').alloc().init()
flex=ObjCClass('UIBarButtonItem').alloc().initWithBarButtonSystemItem_target_action_(5,None,None)
bar.items=[flex,btn]
textview.inputAccessoryView=bar
view.add_subview(textview)
view.present()
