Make Copy and Cut buttons disappear when no text is selected (#730)

This commit is contained in:
nixls 2020-10-04 23:13:58 +02:00 committed by GitHub
parent c73dfe8ca0
commit d6de7e2ba8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -503,7 +503,25 @@ void Textbox::OnTextInput(String text)
void Textbox::OnMouseClick(int x, int y, unsigned button)
{
if (button == SDL_BUTTON_RIGHT)
{
if (HasSelection())
{
menu->RemoveItem(0);
menu->RemoveItem(1);
menu->RemoveItem(2);
menu->AddItem(ContextMenuItem("Cut", 1, true));
menu->AddItem(ContextMenuItem("Copy", 0, true));
menu->AddItem(ContextMenuItem("Paste", 2, true));
}
else
{
menu->RemoveItem(0);
menu->RemoveItem(1);
menu->RemoveItem(2);
menu->AddItem(ContextMenuItem("Paste", 2, true));
}
}
if (button != SDL_BUTTON_RIGHT)
{
mouseDown = true;