Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
This repository was archived by the owner on Feb 26, 2023. It is now read-only.

Enhance EditTexts #494

Description

@SantiagoRivera92

I usually implement OnEditorActionListeners on the EditTexts in my forms, so when the user presses Enter, I can hide the keyboard and pass the focus to the next EditText. I'd really love a new annotation (something like @EditorAction) which behaves exactly as @click does.

Activity

  1. pyricau commented on Feb 27, 2013

    @pyricau
    Contributor

    Sure, why not. If you want this to move forward, you should start by proposing an API (which annotations to use, where and how), and also stating what the generated code should look like.

  2. SantiagoRivera92 commented on Feb 28, 2013

    @SantiagoRivera92
    Author

    Ok, the annotations would be something like this:

    @EditorAction(R.id.whatever)
    void method(){}
    
    @EditorAction(R.id.whatever)
    void method(TextView tv){}
    
    @EditorAction(R.id.whatever)
    void method(TextView tv, int actionId, KeyEvent event){}
    
    @EditorAction
    void whatever(){} // When R.id.whatever OnEditorActionListener.onEditorAction() is triggered
    
    @EditorAction
    void whatever(TextView tv){} // When R.id.whatever OnEditorActionListener.onEditorAction() is triggered
    
    @EditorAction
    void whatever(TextView tv, int actionId, KeyEvent event){} // When R.id.whatever OnEditorActionListener.onEditorAction() is triggered
    

    The generated code would look like this:

    TextView view = (TextView) findViewById(id.whatever);
            if (view != null) {
                view.setOnEditorActionListener(new OnEditorActionListener() {
    
    
                    @Override
                    onEditorAction(TextView tv, int actionId, KeyEvent event) {
                           method();
                           method(tv);
                           method(tv, actionId, event);
                           whatever();
                           whatever(tv);
                           whatever(tv, actionId, event);
                    }
    
                }
                );
            }
    

    Of course this is just a silly case: a user would only implement one of those.

    And it would behave exactly as @click does, the code would appear in afterSetContentView_();

  3. DayS commented on May 23, 2013

    @DayS
    Contributor

    Isn't it quite the same as @TextChanged ?

  4. SantiagoRivera92 commented on May 23, 2013

    @SantiagoRivera92
    Author

    Nope. onEditorAction triggers on events like user pressing Enter or IME buttons, not text.

  5. DayS commented on May 23, 2013

    @DayS
    Contributor

    Ok then. You can work on this feature if you want. It should be the same thing than @TextChanged even if it would also be concerned by this issue.

  6. DayS commented on May 11, 2014

    @DayS
    Contributor

    Merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions