mirror of https://github.com/AxioDL/metaforce.git
Remove old text input methods
This commit is contained in:
parent
13863d3256
commit
5951beaf9e
|
@ -70,6 +70,10 @@ protected:
|
|||
ITextInputView(ViewResources& res, View& parentView,
|
||||
IControlBinding* controlBinding)
|
||||
: Control(res, parentView, controlBinding) {}
|
||||
public:
|
||||
virtual void clipboardCopy() {}
|
||||
virtual void clipboardCut() {}
|
||||
virtual void clipboardPaste() {}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -50,8 +50,7 @@ struct DeferredWindowEvents : public boo::IWindowCallback
|
|||
SpecialKeyDown,
|
||||
SpecialKeyUp,
|
||||
ModKeyDown,
|
||||
ModKeyUp,
|
||||
UTF8FragmentDown
|
||||
ModKeyUp
|
||||
} m_type;
|
||||
|
||||
boo::SWindowCoord m_coord;
|
||||
|
@ -63,7 +62,6 @@ struct DeferredWindowEvents : public boo::IWindowCallback
|
|||
unsigned long m_charcode;
|
||||
boo::ESpecialKey m_special;
|
||||
bool m_isRepeat;
|
||||
std::string m_fragment;
|
||||
|
||||
void dispatch(Receiver& rec) const
|
||||
{
|
||||
|
@ -114,9 +112,6 @@ struct DeferredWindowEvents : public boo::IWindowCallback
|
|||
case Type::ModKeyUp:
|
||||
rec.modKeyUp(m_mods);
|
||||
break;
|
||||
case Type::UTF8FragmentDown:
|
||||
rec.utf8FragmentDown(m_fragment);
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
@ -245,13 +240,6 @@ struct DeferredWindowEvents : public boo::IWindowCallback
|
|||
m_cmds.back().m_mods = mod;
|
||||
}
|
||||
|
||||
void utf8FragmentDown(const std::string& str)
|
||||
{
|
||||
std::unique_lock<std::mutex> lk(m_mt);
|
||||
m_cmds.emplace_back(Command::Type::UTF8FragmentDown);
|
||||
m_cmds.back().m_fragment = str;
|
||||
}
|
||||
|
||||
boo::ITextInputCallback* getTextInputCallback() {return m_rec.getTextInputCallback();}
|
||||
|
||||
void dispatchEvents()
|
||||
|
|
|
@ -56,7 +56,6 @@ public:
|
|||
void specialKeyUp(boo::ESpecialKey key, boo::EModifierKey mods);
|
||||
void modKeyDown(boo::EModifierKey mod, bool isRepeat);
|
||||
void modKeyUp(boo::EModifierKey mod);
|
||||
void utf8FragmentDown(const std::string& str);
|
||||
boo::ITextInputCallback* getTextInputCallback() {return m_activeTextView;}
|
||||
|
||||
void dispatchEvents() {m_events.dispatchEvents();}
|
||||
|
|
|
@ -72,9 +72,7 @@ public:
|
|||
void mouseMove(const boo::SWindowCoord&);
|
||||
void mouseEnter(const boo::SWindowCoord&);
|
||||
void mouseLeave(const boo::SWindowCoord&);
|
||||
void charKeyDown(unsigned long, boo::EModifierKey, bool);
|
||||
void specialKeyDown(boo::ESpecialKey, boo::EModifierKey, bool);
|
||||
void utf8FragmentDown(const std::string&);
|
||||
|
||||
bool hasMarkedText() const;
|
||||
std::pair<int,int> markedRange() const;
|
||||
|
|
|
@ -203,7 +203,6 @@ public:
|
|||
virtual void specialKeyUp(boo::ESpecialKey, boo::EModifierKey) {}
|
||||
virtual void modKeyDown(boo::EModifierKey, bool) {}
|
||||
virtual void modKeyUp(boo::EModifierKey) {}
|
||||
virtual void utf8FragmentDown(const std::string&) {}
|
||||
|
||||
virtual void resized(const boo::SWindowRect& root, const boo::SWindowRect& sub);
|
||||
virtual void think() {}
|
||||
|
|
|
@ -108,16 +108,22 @@ void RootView::charKeyDown(unsigned long charCode, boo::EModifierKey mods, bool
|
|||
{
|
||||
if (m_view)
|
||||
m_view->charKeyDown(charCode, mods, isRepeat);
|
||||
//if (m_activeTextView)
|
||||
// m_activeTextView->charKeyDown(charCode, mods, isRepeat);
|
||||
if (m_activeTextView &&
|
||||
(mods & (boo::EModifierKey::Ctrl|boo::EModifierKey::Command)) != boo::EModifierKey::None)
|
||||
{
|
||||
if (charCode == 'c' || charCode == 'C')
|
||||
m_activeTextView->clipboardCopy();
|
||||
else if (charCode == 'x' || charCode == 'X')
|
||||
m_activeTextView->clipboardCut();
|
||||
else if (charCode == 'v' || charCode == 'V')
|
||||
m_activeTextView->clipboardPaste();
|
||||
}
|
||||
}
|
||||
|
||||
void RootView::charKeyUp(unsigned long charCode, boo::EModifierKey mods)
|
||||
{
|
||||
if (m_view)
|
||||
m_view->charKeyUp(charCode, mods);
|
||||
//if (m_activeTextView)
|
||||
// m_activeTextView->charKeyUp(charCode, mods);
|
||||
}
|
||||
|
||||
void RootView::specialKeyDown(boo::ESpecialKey key, boo::EModifierKey mods, bool isRepeat)
|
||||
|
@ -157,12 +163,6 @@ void RootView::modKeyUp(boo::EModifierKey mod)
|
|||
m_activeTextView->modKeyUp(mod);
|
||||
}
|
||||
|
||||
void RootView::utf8FragmentDown(const std::string& str)
|
||||
{
|
||||
//if (m_activeTextView)
|
||||
// m_activeTextView->utf8FragmentDown(str);
|
||||
}
|
||||
|
||||
View* RootView::setContentView(View* view)
|
||||
{
|
||||
View* ret = m_view;
|
||||
|
|
|
@ -288,46 +288,6 @@ void TextField::clipboardPaste()
|
|||
}
|
||||
}
|
||||
|
||||
void TextField::charKeyDown(unsigned long charCode, boo::EModifierKey mods, bool isRepeat)
|
||||
{
|
||||
if (charCode < 0x20)
|
||||
return;
|
||||
|
||||
if ((mods & (boo::EModifierKey::Ctrl|boo::EModifierKey::Command)) != boo::EModifierKey::None)
|
||||
{
|
||||
if (charCode == 'c' || charCode == 'C')
|
||||
clipboardCopy();
|
||||
else if (charCode == 'v' || charCode == 'V')
|
||||
clipboardPaste();
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_selectionCount)
|
||||
{
|
||||
std::string newStr(m_textStr.cbegin(), (UTF8Iterator(m_textStr.cbegin()) + m_selectionStart).iter());
|
||||
utf8proc_uint8_t theChar[5] = {};
|
||||
utf8proc_ssize_t sz = utf8proc_encode_char(charCode, theChar);
|
||||
if (sz > 0)
|
||||
newStr += (char*)theChar;
|
||||
newStr.append((UTF8Iterator(m_textStr.cbegin()) + m_selectionStart + m_selectionCount).iter(),
|
||||
m_textStr.cend());
|
||||
size_t selStart = m_selectionStart;
|
||||
setText(newStr);
|
||||
setCursorPos(selStart + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string newStr(m_textStr.cbegin(), (UTF8Iterator(m_textStr.cbegin()) + m_cursorPos).iter());
|
||||
utf8proc_uint8_t theChar[5] = {};
|
||||
utf8proc_ssize_t sz = utf8proc_encode_char(charCode, theChar);
|
||||
if (sz > 0)
|
||||
newStr += (char*)theChar;
|
||||
newStr.append((UTF8Iterator(m_textStr.cbegin()) + m_cursorPos).iter(), m_textStr.cend());
|
||||
setText(newStr);
|
||||
setCursorPos(m_cursorPos + 1);
|
||||
}
|
||||
}
|
||||
|
||||
void TextField::specialKeyDown(boo::ESpecialKey key, boo::EModifierKey mods, bool isRepeat)
|
||||
{
|
||||
std::unique_lock<std::recursive_mutex> lk(m_textInputLk);
|
||||
|
@ -426,29 +386,6 @@ void TextField::specialKeyDown(boo::ESpecialKey key, boo::EModifierKey mods, boo
|
|||
}
|
||||
}
|
||||
|
||||
void TextField::utf8FragmentDown(const std::string& str)
|
||||
{
|
||||
std::string saniStr = SanitizeUTF8TextLine(str.data(), str.size());
|
||||
if (m_selectionCount)
|
||||
{
|
||||
std::string newStr(m_textStr.cbegin(), (UTF8Iterator(m_textStr.cbegin()) + m_selectionStart).iter());
|
||||
newStr += saniStr;
|
||||
size_t newSel = UTF8Iterator(newStr.cbegin()).countTo(newStr.cend());
|
||||
newStr.append((UTF8Iterator(m_textStr.cbegin()) + m_selectionStart + m_selectionCount).iter(), m_textStr.cend());
|
||||
setText(newStr);
|
||||
setCursorPos(newSel);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string newStr(m_textStr.cbegin(), (UTF8Iterator(m_textStr.cbegin()) + m_cursorPos).iter());
|
||||
newStr += saniStr;
|
||||
size_t newSel = UTF8Iterator(newStr.cbegin()).countTo(newStr.cend());
|
||||
newStr.append((UTF8Iterator(m_textStr.cbegin()) + m_cursorPos).iter(), m_textStr.cend());
|
||||
setText(newStr);
|
||||
setCursorPos(newSel);
|
||||
}
|
||||
}
|
||||
|
||||
bool TextField::hasMarkedText() const
|
||||
{
|
||||
std::unique_lock<std::recursive_mutex> lk(m_textInputLk);
|
||||
|
|
Loading…
Reference in New Issue