Text input is now working in all classes inheriting from EditableWidget

(specifically, DataGridWidget and RomListWidget are now working).

More work is required for PromptWidget, since it was created before
EditableWidget existed, and hence duplicates a lot of that classes code.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2914 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2014-06-10 21:04:36 +00:00
parent 90248b2701
commit aa6c1b3d58
4 changed files with 26 additions and 10 deletions

View File

@ -282,14 +282,10 @@ int DataGridWidget::findItem(int x, int y)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool DataGridWidget::handleText(char text)
{
if (_editMode)
if(_editMode)
{
// Class EditableWidget handles all text editing related key presses for us
if(EditableWidget::handleText(text))
{
setDirty(); draw();
return true;
}
return EditableWidget::handleText(text);
}
return false;
}
@ -305,7 +301,12 @@ bool DataGridWidget::handleKeyDown(StellaKey key, StellaMod mod)
bool handled = true;
bool dirty = false;
if (!_editMode)
if (_editMode)
{
// Class EditableWidget handles all single-key presses for us
handled = EditableWidget::handleKeyDown(key, mod);
}
else
{
switch(key)
{

View File

@ -137,7 +137,14 @@ void PromptWidget::printPrompt()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool PromptWidget::handleKeyDown(StellaKey key, StellaMod mod, char ascii)
bool PromptWidget::handleText(char text)
{
return false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool PromptWidget::handleKeyDown(StellaKey key, StellaMod mod)
{
int i;
bool handled = true;
@ -409,6 +416,7 @@ bool PromptWidget::handleKeyDown(StellaKey key, StellaMod mod, char ascii)
else if (instance().eventHandler().kbdAlt(mod))
{
}
#if 0
else if (isprint(ascii))
{
for (i = _promptEndPos - 1; i >= _currentPos; i--)
@ -417,6 +425,7 @@ bool PromptWidget::handleKeyDown(StellaKey key, StellaMod mod, char ascii)
putchar(ascii);
scrollToCurrent();
}
#endif
else
handled = false;
break;

View File

@ -70,7 +70,8 @@ class PromptWidget : public Widget, public CommandSender
void handleMouseDown(int x, int y, int button, int clickCount);
void handleMouseWheel(int x, int y, int direction);
bool handleKeyDown(StellaKey key, StellaMod mod, char ascii);
bool handleText(char text);
bool handleKeyDown(StellaKey key, StellaMod mod);
void handleCommand(CommandSender* sender, int cmd, int data, int id);
// Account for the extra width of embedded scrollbar

View File

@ -292,7 +292,12 @@ bool RomListWidget::handleKeyDown(StellaKey key, StellaMod mod)
bool handled = true;
int oldSelectedItem = _selectedItem;
if(!_editMode)
if (_editMode)
{
// Class EditableWidget handles all single-key presses for us
handled = EditableWidget::handleKeyDown(key, mod);
}
else
{
switch (key)
{