Author Topic: Temporarily disable button press for a set time.  (Read 3027 times)

dukpoki

  • Sr. Member
  • ****
  • Posts: 138
    • View Profile
Temporarily disable button press for a set time.
« on: July 25, 2019, 11:32:17 AM »
How to disable a button press for an xx amount of time on transition?  For example, let's say I want to disable the up and down keys for 5 seconds whenever you load a layout.  After 5 seconds, they can then be functional.

zpaolo11x

  • Hero Member
  • *****
  • Posts: 1233
    • View Profile
    • My deviantart page
Re: Temporarily disable button press for a set time.
« Reply #1 on: July 31, 2019, 02:35:56 AM »
Hi dukpoki, I see you had no answer to your question, I don't have the documentation at hand to check but this can be done this way. What you need is:

Define a boolean like "deafkeys = true" at the beginning of the layout

Add a signal callback function, when the signal is "up" or "down" check if deafkeys is true or false and if it's true don't process the signal.

Add a tick callback to your theme, the parameter tick_time of the tick callback function is the time since the start of the layout. Just check at the beginning of the tick function if tick_time is greater than your desired delay time and turn deafkeys to off
 

dukpoki

  • Sr. Member
  • ****
  • Posts: 138
    • View Profile
Re: Temporarily disable button press for a set time.
« Reply #2 on: August 02, 2019, 09:41:33 AM »
Thanks zpaolo.  I haven't tried it yet but I'll give it a go later.