omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Textfields delegator does not work

    Pythonista
    delegators
    3
    4
    1906
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • sendog3c
      sendog3c last edited by

      Hello community:

      Here I am again looking for help about a textfields delegators. I have used the example of delegator found here but does not work to me. Would you please help explain me how it is works. Thanks.

      import ui
      import console
      
      textfield1 = ui.TextField()
      textfield2 = ui.TextField()
      textview1 = ui.TextView()
      label1= ui.Label()
      
      class MyTextFieldDelegate (object):
          def textfield_should_begin_editing(self, textfield):
              alert_result = console.alert("textfield_should_begin_editing")
              
          def textfield_did_begin_editing(self, textfield):
          		alert_result = console.alert("textfield_did_begin_editing")
          		
          def textfield_did_end_editing(self, textfield):
          		alert_result = console.alert("textfield_did_end_editing")
          		
          def textfield_should_return(self, textfield):
          		alert_result = console.alert("textfield_should_return")
          		
          def textfield_should_change(self, textfield, range, replacement):
              alert_result = console.alert("textfield_should_change")
              
          def textfield_did_change(self, textfield):
              alert_result = console.alert("textfield_did_change")
              
      
      
      def button_tapped(sender):
      	
          button_definition = sender.title
          
          if button_definition == "SUM":
          	
          	label1 = sender.superview['label1'].text = "+"
          	
          	textfield1 = MyTextFieldDelegate()
          	
          	#sender.superview['textfield1'] = MyTextFieldDelegate()
          	
          if button_definition == "SUBS":
          	#alert_result = console.alert(button_definition)
          	label2 = sender.superview['label1'].text = "-"
          			
          if button_definition == "MULT":
          	#alert_result = console.alert(button_definition)
          	label3 = sender.superview['label1'].text = "*"	
          	
          if button_definition == "DIV":
          	#alert_result = console.alert(button_definition)
          	label4 = sender.superview['label1'].text = "/"	
          
      def funcion_suma(sender, button_definition):
          	pass
          	
      def funcion_multi(sender, button_definition):
          	pass
          	
      def funcion_division(sender, button_definition):
          	pass
      
      ui.load_view('MATHFUN').present('sheet')
      
      mikael 1 Reply Last reply Reply Quote 0
      • mikael
        mikael @sendog3c last edited by

        @sendog3c said:

        textfield1 = MyTextFieldDelegate()

        You need to set your delegate as a delegate.

        textfield1.delegate = MyTextFieldDelegate()
        
        1 Reply Last reply Reply Quote 1
        • sendog3c
          sendog3c last edited by

          Hi Mikael:

          It is non working still 🥺

          cvp 1 Reply Last reply Reply Quote 0
          • cvp
            cvp @sendog3c last edited by

            @sendog3c problem of sequence 😀

            v = ui.load_view('MATHFUN')
            v['textfield1'].delegate = MyTextFieldDelegate()
            v.present('sheet')
            
            1 Reply Last reply Reply Quote 0
            • First post
              Last post
            Powered by NodeBB Forums | Contributors