2017-02-07 04:59:30 +00:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
2017-01-30 15:16:55 +00:00
|
|
|
|
using OpenTK.Input;
|
2017-01-10 22:43:00 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Primitives;
|
2017-01-30 15:16:55 +00:00
|
|
|
|
using osu.Framework.Input;
|
2017-01-10 22:43:00 +00:00
|
|
|
|
using osu.Game.Graphics;
|
2017-02-08 02:19:58 +00:00
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2017-01-10 22:43:00 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Select
|
|
|
|
|
{
|
2017-02-08 06:13:56 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// A textbox which holds focus eagerly.
|
|
|
|
|
/// </summary>
|
2017-02-19 08:59:22 +00:00
|
|
|
|
public class SearchTextBox : FocusedTextBox
|
2017-01-10 22:43:00 +00:00
|
|
|
|
{
|
|
|
|
|
public SearchTextBox()
|
|
|
|
|
{
|
|
|
|
|
Height = 35;
|
|
|
|
|
Add(new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new TextAwesome
|
|
|
|
|
{
|
|
|
|
|
Icon = FontAwesome.fa_search,
|
|
|
|
|
Origin = Anchor.CentreRight,
|
|
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
|
Margin = new MarginPadding { Right = 10 },
|
2017-03-20 04:48:06 +00:00
|
|
|
|
TextSize = 20
|
2017-01-10 22:43:00 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
2017-02-08 05:01:17 +00:00
|
|
|
|
|
|
|
|
|
PlaceholderText = "type to search";
|
2017-01-10 22:43:00 +00:00
|
|
|
|
}
|
2017-02-03 10:12:57 +00:00
|
|
|
|
|
2017-01-30 15:16:55 +00:00
|
|
|
|
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
|
|
|
|
{
|
2017-02-09 03:33:24 +00:00
|
|
|
|
if (HandlePendingText(state)) return true;
|
|
|
|
|
|
2017-02-08 06:30:20 +00:00
|
|
|
|
if (!state.Keyboard.ControlPressed && !state.Keyboard.ShiftPressed)
|
|
|
|
|
{
|
|
|
|
|
switch (args.Key)
|
|
|
|
|
{
|
|
|
|
|
case Key.Left:
|
|
|
|
|
case Key.Right:
|
|
|
|
|
case Key.Up:
|
|
|
|
|
case Key.Down:
|
|
|
|
|
case Key.Enter:
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-23 11:01:44 +00:00
|
|
|
|
if (state.Keyboard.ShiftPressed)
|
|
|
|
|
{
|
|
|
|
|
switch (args.Key)
|
|
|
|
|
{
|
|
|
|
|
case Key.Delete:
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-30 15:16:55 +00:00
|
|
|
|
return base.OnKeyDown(state, args);
|
|
|
|
|
}
|
2017-01-10 22:43:00 +00:00
|
|
|
|
}
|
|
|
|
|
}
|