Button Repeat

Questions about deployment and use of Air Manager Instruments

Moderators: russ, Ralph

Post Reply
Message
Author
auditdata
Posts: 63
Joined: Sun Jun 21, 2020 2:06 pm

Button Repeat

#1 Post by auditdata »

I do feel a fool for asking but I just can't find if this is possible!
If you press a button can it repeat the command until released.
For Example

Code: Select all

button_2_6=button_add("BGreen.png", "BRed.png", 560, 120, 100, 100, function()
    xpl_command("sim/general/up")
end)
text_2_6 = txt_add("Up", "font:arimo_regular.ttf; size:15; halign:center; color: white; ", 560, 180, 100, 100)
Can the "Up" function keep repeating until released?

auditdata
Posts: 63
Joined: Sun Jun 21, 2020 2:06 pm

Re: Button Repeat

#2 Post by auditdata »

Ignore me I am a fool!!!
I already asked this question and had a response.
Doh

auditdata
Posts: 63
Joined: Sun Jun 21, 2020 2:06 pm

Re: Button Repeat

#3 Post by auditdata »

As there was a missing statement in the answer I had some time ago I will just repeat the correct code for this using embedded functions for completeness or if theist is stumbled across

Code: Select all

button_2_6=button_add("BGreen.png", "BRed.png", 560, 120, 100, 100, function(press)
    xpl_command("sim/general/up","BEGIN") 
end,
    function(release)
        xpl_command("sim/general/up","END")
    end)
text_2_6 = txt_add("Up", "font:arimo_regular.ttf; size:15; halign:center; color: white; ", 560, 180, 100, 100)

User avatar
jph
Posts: 2846
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: Button Repeat

#4 Post by jph »

Thanks for adding the info, it is very useful for people searching the forums.
Glad you got it sorted.
Joe. CISSP, MSc.

Post Reply