A button with two functions defined by pressing time.

Help creating logic scripts for Air Manager Instruments

Moderators: russ, Ralph

Post Reply
Message
Author
User avatar
Marcnamara2021
Posts: 83
Joined: Wed Dec 01, 2021 6:00 am
Location: Sao Jose dos Campos, SP

A button with two functions defined by pressing time.

#1 Post by Marcnamara2021 »

Dear AM team

I ran into a problem and couldn't solve it. I only have one button. A quick click it triggers a function on the screen. The same button if pressed for 3 seconds they turn off the instrument inserted a black screen.

Could you give me some guidance on how to do it?

Thanks

User avatar
Ralph
Posts: 7878
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: A button with two functions defined by pressing time.

#2 Post by Ralph »

You'll have to work with the released callback and a timer, the timer is started in the pressed callback and stopped in the release callback.

User avatar
Crunchmeister
Posts: 222
Joined: Tue Aug 10, 2021 2:06 pm

Re: A button with two functions defined by pressing time.

#3 Post by Crunchmeister »

Seta timer that fires when the button is pressed.

In the release callback, if the time held is less than 3 seconds, then it fires the event for the quick click. If timer reached 3 seconds, then use the long press event.
Last edited by Crunchmeister on Thu May 19, 2022 4:17 pm, edited 1 time in total.
- Ryzen 5950x, 64GB 3600MHz RAM, RTX3070Ti

Simstrumentation Instrument dev
Free Air Manager instruments for MSFS available at http://www.simstrumentation.com

User avatar
Marcnamara2021
Posts: 83
Joined: Wed Dec 01, 2021 6:00 am
Location: Sao Jose dos Campos, SP

Re: A button with two functions defined by pressing time.

#4 Post by Marcnamara2021 »

Thank You guys. I will try.

Marcio

User avatar
Marcnamara2021
Posts: 83
Joined: Wed Dec 01, 2021 6:00 am
Location: Sao Jose dos Campos, SP

Re: A button with two functions defined by pressing time.

#5 Post by Marcnamara2021 »

Hi I tried several ways to establish this function and I couldn't. Could you explain better, please, exemplifying a script, or pointing out where in the Forum there is a similar one, if possible.

tank You

User avatar
Crunchmeister
Posts: 222
Joined: Tue Aug 10, 2021 2:06 pm

Re: A button with two functions defined by pressing time.

#6 Post by Crunchmeister »

Take a look at the code for the CLR button on the G1000 NXi bezel. It has a long press function using a timer.
Last edited by Crunchmeister on Mon May 23, 2022 2:30 pm, edited 1 time in total.
- Ryzen 5950x, 64GB 3600MHz RAM, RTX3070Ti

Simstrumentation Instrument dev
Free Air Manager instruments for MSFS available at http://www.simstrumentation.com

User avatar
Marcnamara2021
Posts: 83
Joined: Wed Dec 01, 2021 6:00 am
Location: Sao Jose dos Campos, SP

Re: A button with two functions defined by pressing time.

#7 Post by Marcnamara2021 »

Hi Guys

Thank You for the information. The long press button is ok now.

Regards

Marcio

Post Reply