|
1 | 1 | #pragma once |
2 | | -#include <climits> |
3 | | -#include <Geode/binding/CCTextInputNode.hpp> |
| 2 | +#include <limits> |
| 3 | +#include <string> |
| 4 | +#include <Geode/Geode.hpp> |
| 5 | +#include <Geode/modify/CCTextInputNode.hpp> |
4 | 6 |
|
5 | 7 | class $modify(CCTextInputNode) { |
6 | 8 | public: |
7 | | - bool init(float width, float height, char const* placeholder, char const* textFont, int fontSize, char const* labelFont) { |
| 9 | + bool init(float width, float height, const char* placeholder, const char* textFont, int fontSize, const char* labelFont) { |
8 | 10 | if (!CCTextInputNode::init(width, height, placeholder, textFont, fontSize, labelFont)) |
9 | 11 | return false; |
10 | | - this->setMaxLabelLength(INT_MAX); |
11 | | - this->setAllowedChars(gd::string()); |
| 12 | + CCTextInputNode::setMaxLabelLength(std::numeric_limits<int>::max()); |
12 | 13 | return true; |
13 | 14 | } |
14 | 15 |
|
15 | 16 | void setMaxLabelLength(int v) { |
16 | | - CCTextInputNode::setMaxLabelLength(INT_MAX); |
| 17 | + CCTextInputNode::setMaxLabelLength(std::numeric_limits<int>::max()); |
17 | 18 | } |
18 | 19 |
|
19 | | - bool onTextFieldInsertText(cocos2d::CCTextFieldTTF* pSender, char const* text, int nLen, cocos2d::enumKeyCodes keyCodes) { |
| 20 | + bool onTextFieldInsertText(cocos2d::CCTextFieldTTF* pSender, const char* text, int nLen, cocos2d::enumKeyCodes keyCodes) { |
20 | 21 | if (text && nLen > 0) { |
21 | 22 | try { |
22 | 23 | auto cur = this->getString(); |
23 | | - cur.append(text, static_cast<size_t>(nLen)); |
24 | | - this->setString(cur); |
| 24 | + std::string s = cur.c_str(); |
| 25 | + s.append(text, static_cast<size_t>(nLen)); |
| 26 | + this->setString(s.c_str()); |
25 | 27 | return true; |
26 | 28 | } catch (...) {} |
27 | 29 | } |
|
0 commit comments