# How to check the dot button clicked or not

**URL:** <https://discuss.kotlinlang.org/t/how-to-check-the-dot-button-clicked-or-not/5400>\
**Category:** Android\
**Created:** [November 14, 2017, 10:46am UTC](https://discuss.kotlinlang.org/t/how-to-check-the-dot-button-clicked-or-not/5400 "2017-11-14T10:46:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![syedyasin86](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@syedyasin86](https://discuss.kotlinlang.org/u/syedyasin86)\
**Post date:** [November 14, 2017, 10:46am UTC](https://discuss.kotlinlang.org/t/how-to-check-the-dot-button-clicked-or-not/5400/1 "2017-11-14T10:46:41Z")

</div>

I am newbie to Kotlin Android,

I am trying to create an calculator app, In my i need to disable the dot(.) button if the button clicked.

Expecting result  
.dot should be entered only once.

**Here is my code**

```
package com.tripbegins.calculator

import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.Button
import com.tripbegins.calculator.R.id.*
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)
}

var emptyText = true
fun numberEvents(view: View) {
var checkButton:Boolean = false
    if(emptyText){
        viewResult.setText("")
    }
    emptyText = false
    var button = view as Button
    var isClicked = viewResult.text.toString()
    when (button.id) {
        buttonOne.id -> isClicked += "1"
        buttonTwo.id -> isClicked += "2"
        buttonThree.id -> isClicked += "3"
        dotButton.id-> isClicked+="."
    }
       viewResult.setText(isClicked)
}

var operation ="+"
var oldValues:String? = null
fun mathOperation(view: View){
    var mathButton = view as Button
    var isClicked = viewResult.text.toString()

    when(mathButton.id){
        plusButton.id-> {
            operation = "+"
        }
        minusButton.id->{
            operation="-"
        }
        mulButton.id->{
            operation="*"
        }

    }
    oldValues = viewResult.text.toString()
    emptyText = true
}

fun Calculate(view: View){

    var newValues = viewResult.text.toString()
    var calulateButton:Double? = null
    when(operation){
        "+"-> { calulateButton = oldValues!!.toDouble() + newValues.toDouble() }
        "-"-> { calulateButton = oldValues!!.toDouble() - newValues.toDouble() }
        "*"-> { calulateButton = oldValues!!.toDouble() * newValues.toDouble() }

    }
    viewResult.setText(calulateButton.toString())
    emptyText=true
}
fun clearFunction(view: View){
    viewResult.setText("")
}
}

```

Kindly suggest me an code to restrict the .dot button to be pressed multiple times

---

<div class="post-metadata">

**Author:** ![pdvrieze](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/pdvrieze/32/1882_2.png) [@pdvrieze](https://discuss.kotlinlang.org/u/pdvrieze)\
**Post date:** [November 16, 2017, 8:57am UTC](https://discuss.kotlinlang.org/t/how-to-check-the-dot-button-clicked-or-not/5400/2 "2017-11-16T08:57:35Z")

</div>

This is an Android, not Kotlin problem, but buttons have an `enabled` property that you can set to `false`.
