question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature request] Add return Press event for the TextView component.

See original GitHub issue

From @bachras on May 4, 2017 14:1

Hi,

I am trying to implement TexView and submit it by pressing return button. However instead of submitting cursor goes to new line and doesn’t do anything else. I have tried all examples i could found online, i also install this examples app and noticed that it is the same behaviour.

I added alert() :

submit(args) {
        alert("Submit Text: " + this.tvtext);
        let textview: TextView = <TextView>args.object;
        if (isAndroid) {
            textview.android.clearFocus();
        }
    }

But nothing is alerted after return(Send) button is clicked. Does anyone have idea what could be wrong? Thank you in advance.

Copied from original issue: NativeScript/nativescript-sdk-examples-ng#183

<bountysource-plugin>

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource. </bountysource-plugin>

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:17 (5 by maintainers)

github_iconTop GitHub Comments

7reactions
tsonevncommented, Sep 25, 2017

Hi @bachras, @sitefinitysteve, @bradmartin, @hairen, I changed the label of the issue as a new feature request. If there is an interest in similar functionality, this feature would be available for some of the next NativeScript versions

4reactions
KarineLiuticommented, Jul 21, 2019

Hello @KarineLiuti, are you sure it works? Because we tried this lot of time and still not working…

<TextField hint="Feedback" text="" returnKeyType="done" @returnPress="submit()" />

Yes. I did this in my code. Look the opa() method:

<template>
  <Page class="page">
    <ActionBar title="Home" class="action-bar" />
    <ScrollView>
      <StackLayout class="home-panel">
        <!--Add your page content here-->
        <Label v-if="amountValue" textWrap="true" :text="amountValue" class="h2 description-label" />
        <Label textWrap="true" text="Qual foi o valor da venda?" class="h2 description-label" />
        <TextField v-model="textFieldValue" keyboardType="number"
          returnKeyType="done" @returnPress="opa()"
          hint="Digite o valor da venda..." />
        <Button class="btn btn-primary" text="Bora lá" @tap="opa"></Button>
      </StackLayout>
    </ScrollView>
  </Page>
</template>

<script>
import RegisterCommission from './RegisterCommission'
export default {
  props: {
    amountValue: ''
  },
  data () {
    return {
      textFieldValue: ''
    };
  },
  methods: {
    onButtonTap() {
      console.log("Button was pressed");
    },
    opa() {
      this.isTyped = true;
      this.$navigateTo(RegisterCommission, {
        clearHistory: false,
        props: {
          valueSelled: this.textFieldValue
        }
      });
    }
  }
}
</script>

<style scoped>
.home-panel {
    vertical-align: center;
    font-size: 20;
    margin: 15;
}
.description-label {
    margin-bottom: 15;
}
</style>
Read more comments on GitHub >

github_iconTop Results From Across the Web

TextView - Android Developers
Returns true, only while processing a touch gesture, if the initial touch down event caused focus to move to the text view and...
Read more >
How to set the part of the text view is clickable - Stack Overflow
getInstance() // without LinkMovementMethod, link can not click this. ... Here is a Kotlin method to make parts of a TextView clickable:
Read more >
Android Threading: All You Need to Know - Toptal
The main thread is responsible for dispatching events to the appropriate user interface widgets as well as communicating with components from the Android...
Read more >
Android - Greeter App - Add Button - Get Text Input From User
Android - Greeter App - Add Button - Handle Button Click Event - Get ... App. We will use components like buttons, edit...
Read more >
Android - TextView Control - Tutorialspoint
TextView Attributes ; 4. android:editable. If set to true, specifies that this TextView has an input method. ; 5. android:fontFamily. Font family (named...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found