// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System; using osu.Framework.Input.Bindings; using osu.Framework.Threading; namespace osu.Game.Extensions { public static class DrawableExtensions { /// /// Helper method that is used while doesn't support repetitions of . /// Simulates repetitions by continually invoking a delegate according to the default key repeat rate. /// /// /// The returned delegate can be cancelled to stop repeat events from firing (usually in ). /// /// The which is handling the repeat. /// The to schedule repetitions on. /// The to be invoked once immediately and with every repetition. /// A which can be cancelled to stop the repeat events from firing. public static ScheduledDelegate BeginKeyRepeat(this IKeyBindingHandler handler, Scheduler scheduler, Action action) { action(); ScheduledDelegate repeatDelegate = new ScheduledDelegate(action, handler.Time.Current + 250, 70); scheduler.Add(repeatDelegate); return repeatDelegate; } } }