cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mpezzutti
Level: Powered On

Disabling a button once it is pressed

Hello
I would like to disable the button once I pressed it once.
Thank you
1 ACCEPTED SOLUTION

Accepted Solutions
v-yutliu-msft
Level 10

Re: Disabling a button once it is pressed

Hi @mpezzutti ,

Do you want the button disabled after clicking once?

I suggest you use a variable to justify.

Set the button's OnSelect:

If(IsBlank(vari),action,false);Set(vari,1)

Then, the action can only execute once beacuse the variable will not be null after clicking the button once.

 

 

Best regards,

Community Support Team _ Phoebe Liu

4 REPLIES 4
cwebb365
Level 8

Re: Disabling a button once it is pressed

don't know if there is easiers way but you could set an IF function in your DisplayMode property on the button you want to disable. Then use a variable to key off of. On the screen visable property initialize a variable with updatecontext({btndisabled:false}). So whatever it is that "Disables" that button, if it's an onSelect then in that property you can trigger an updatecontext to set the variable to opposite of what it currently is. So use onSelect to: updatecontext({btndisabled:!btndisabled}) and anything you do that onselect or whatever event fires it will set the opposite. 

 

Anyway, set the IF statement on the button you want disabled DisplayMode to IF(btndisabled,DisplayMode.disabled,DisplayMode.Edit) this should do the trick. 

Highlighted
hnguy71
Level 8

Re: Disabling a button once it is pressed

I'll expand on @cwebb365 idea,

Using a screen's OnVisible property do something like this:

Set(_DisableButton, !_DisableButton)

 then on the button's OnSelect property do something like this:

If(!_DisableButton, UpdateContext({_DisableButton: true});Do_Something_Only_Once)

That way it'll only fire once. Or you can set a variable between 0 and 1 and if it's a particular value you set a property to view or false.

v-yutliu-msft
Level 10

Re: Disabling a button once it is pressed

Hi @mpezzutti ,

Do you want the button disabled after clicking once?

I suggest you use a variable to justify.

Set the button's OnSelect:

If(IsBlank(vari),action,false);Set(vari,1)

Then, the action can only execute once beacuse the variable will not be null after clicking the button once.

 

 

Best regards,

Community Support Team _ Phoebe Liu

mpezzutti
Level: Powered On

Re: Disabling a button once it is pressed

hi  Phoebe Liu

This works . Thanks so much