eDebug("cursor is %d", cursor);
para->setFont(m_font);
- para->renderString(text, 0);
+ para->renderString(text.empty()?0:text.c_str(), 0);
int glyphs = para->size();
if (m_have_focus)
case evtAction:
if (isVisible())
{
- switch((int)data2)
+ if ((long)data == ASCII_ACTIONS)
{
- case moveLeft:
- m_content->moveCursor(eInputContent::dirLeft);
- break;
- case moveRight:
- m_content->moveCursor(eInputContent::dirRight);
- break;
- case moveHome:
- m_content->moveCursor(eInputContent::dirHome);
- break;
- case moveEnd:
- m_content->moveCursor(eInputContent::dirEnd);
- break;
- case deleteForward:
- m_content->deleteChar(eInputContent::deleteForward);
- break;
- case deleteBackward:
- m_content->deleteChar(eInputContent::deleteBackward);
- break;
- case toggleOverwrite:
- setOverwriteMode(!m_mode);
- break;
- case accept:
- changed();
- mayKillFocus();
+ if ((long)data2 == gotAsciiCode)
+ {
+ if (m_content)
+ {
+ extern int getPrevAsciiCode(); // defined in enigma.cpp
+ return m_content->haveKey(getPrevAsciiCode(), m_mode);
+ }
+ }
+ }
+ else if ((long)data == INPUT_ACTIONS)
+ {
+ switch((long)data2)
+ {
+ case moveLeft:
+ if (m_content)
+ m_content->moveCursor(eInputContent::dirLeft);
+ break;
+ case moveRight:
+ if (m_content)
+ m_content->moveCursor(eInputContent::dirRight);
+ break;
+ case moveHome:
+ if (m_content)
+ m_content->moveCursor(eInputContent::dirHome);
+ break;
+ case moveEnd:
+ if (m_content)
+ m_content->moveCursor(eInputContent::dirEnd);
+ break;
+ case deleteForward:
+ if (m_content)
+ m_content->deleteChar(eInputContent::deleteForward);
+ break;
+ case deleteBackward:
+ if (m_content)
+ m_content->deleteChar(eInputContent::deleteBackward);
+ break;
+ case toggleOverwrite:
+ setOverwriteMode(!m_mode);
+ break;
+ case accept:
+ changed();
+ mayKillFocus();
+ }
+ return 1;
}
- return 1;
}
return 0;
case evtKey:
{
- int key = (int)data;
- int flags = (int)data2;
+ long key = (long)data;
+ long flags = (long)data2;
if (m_content && !(flags & 1)) // only make/repeat, no break
return m_content->haveKey(key, m_mode);
break;
eDebug("focus got in %p", this);
ePtr<eActionMap> ptr;
eActionMap::getInstance(ptr);
- ptr->bindAction("InputActions", 0, 0, this);
- // bind all keys
- ptr->bindAction("", 0, 1, this);
+ ptr->bindAction("InputActions", 0, INPUT_ACTIONS, this);
+ ptr->bindAction("AsciiActions", 0, ASCII_ACTIONS, this);
m_have_focus = 1;
eRCInput::getInstance()->setKeyboardMode(eRCInput::kmAscii);
// fixme. we should use a style for this.
eDebug("focus lostin %p", this);
ePtr<eActionMap> ptr;
eActionMap::getInstance(ptr);
- ptr->unbindAction(this, 0);
- ptr->unbindAction(this, 1);
+ ptr->unbindAction(this, INPUT_ACTIONS);
+ ptr->unbindAction(this, ASCII_ACTIONS);
m_have_focus = 0;
if (m_content)
m_content->validate();