We wanted to use certain keyboard inputs to increment or decrement the dropdown index.
However, whenever we press the specific key/s, the dropdow items gets cleared.
We are assuming since dropdown uses keys to autocomplete, it might be causing the issue.
Below is a sample code.
Kindly guide how we can still use keyboard inputs for increment & decrement
public static DropDown CreateDropdown(Size size, IEnumerable<string> items)
{
var dropDown = new DropDown
{
Size = size,
TextColor = Colors.Gold,
Font = new Font(SystemFont.Bold, 10),
BackgroundColor = new Color(36f / 255f, 36f / 255f, 36f / 255f),
DataStore = items.ToArray(),
};
return dropDown;
}
myDropdown = ETOUtils.CreateDropdown(new Size(90, 25), new List<string>() {"A","B","C","D" });
private void RhinoApp_KeyboardEvent(int key)
{
if (!IsKeyDown(key))
return;
Application.Instance.Invoke(() =>
{
if (key == VK_Q)
{
if (myDropdown.SelectedIndex < myDropdown.Items.Count - 1)
myDropdown.SelectedIndex += 1;
}
else if (key == VK_E)
{
if (myDropdown.SelectedIndex > 0)
myDropdown.SelectedIndex -= 1;
}
});
}
[DllImport("user32.dll")]
private static extern short GetAsyncKeyState(int vKey);
private bool IsKeyDown(int key)
{
return (GetAsyncKeyState(key) & 0x8000) != 0;
}