Jump to content

Creating a long press button function


helibrewer

Recommended Posts

Reworking the GNS530 for FS2020 and want to create a function for the "CLR" button which returns to the default nav page with a long press. Mobiflight already has an event ID to handle the long press, MobiFlight.AS530_CLR_Push_Long, I just need to create a function that detects a long press....thinking probably 2000ms should work.
Link to comment
Share on other sites

No support for Lvars and certain events yet. Their SDK still doesn't work as it should and there's hardly any documentation. We don't want to go the 'hacky' way. Microsoft/Asobo has to get their act together and put more time in their SDK.
Link to comment
Share on other sites

No support for Lvars and certain events yet. Their SDK still doesn't work as it should and there's hardly any documentation. We don't want to go the 'hacky' way. Microsoft/Asobo has to get their act together and put more time in their SDK.

 

Got some help on it. It's just a logic issue, the events are all in place. This works great:

 

----button hold----

 

function button_press()

button_held_timer_id = timer_start(500, 0, button_held)

end

 

function button_held()

timer_stop(button_held_timer_id) --should already be stopped, but just in case.

button_hold_active = true

print("button held!!")

end

 

function instrument_btn_name()

timer_stop(button_held_timer_id)

if (button_hold_active) then

PUT LONG PRESS EVENT CODE HERE

button_hold_active = false

else

PUT CLICK EVENT CODE HERE

print("button click")

end

end

 

//button_id = button_add(img_normal,img_pressed,x,y,width,height,press_callback,release_callback)

button_add(nil, "panel_btn_image.png", PosX, PosY, ImageX, ImageY, button_press, instrument_btn_name)

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...