added selection reset for all widgets derived from EditableWidget

This commit is contained in:
thrust26 2020-11-04 22:44:41 +01:00
parent c8c70ee54b
commit c894d8c080
6 changed files with 11 additions and 0 deletions

View File

@ -259,6 +259,7 @@ void DataGridWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount
if (!isEnabled())
return;
resetSelection();
// First check whether the selection changed
int newSelectedItem;
newSelectedItem = findItem(x, y);

View File

@ -235,6 +235,7 @@ void RomListWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount)
if (!isEnabled())
return;
resetSelection();
// Grab right mouse button for context menu, left for selection/edit mode
if(b == MouseButton::RIGHT)
{

View File

@ -118,12 +118,15 @@ bool EditableWidget::handleKeyDown(StellaKey key, StellaMod mod)
if(StellaModTest::isAlt(mod))
return true;
// Handle Control and Control-Shift keys
if(StellaModTest::isControl(mod) && handleControlKeys(key, mod))
return true;
// Handle Shift keys
if(StellaModTest::isShift(mod) && handleShiftKeys(key))
return true;
// Handle keys without modifiers
return handleNormalKeys(key);
}

View File

@ -110,6 +110,10 @@ class EditableWidget : public Widget, public CommandSender
bool _editable{true};
string _editString;
int _caretPos{0};
// Size of current selected text
// 0 = no selection
// <0 = selected left of caret
// >0 = selected right of caret
int _selectSize{0};
protected:

View File

@ -205,6 +205,7 @@ void ListWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount)
if (!isEnabled())
return;
resetSelection();
// First check whether the selection changed
int newSelectedItem;
newSelectedItem = findItem(x, y);

View File

@ -117,6 +117,7 @@ const Variant& PopUpWidget::getSelectedTag() const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PopUpWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount)
{
resetSelection();
if(!isEditable() || x > _w - dropDownWidth(_font))
{
if(isEnabled() && !myMenu->isVisible())