mirror of
https://github.com/geode-sdk/geode.git
synced 2025-02-17 00:30:26 -05:00
add a fix for CCTextInputNode content size
This commit is contained in:
parent
746164bba8
commit
208ba02279
1 changed files with 31 additions and 0 deletions
31
loader/src/ids/CCTextInputNode.cpp
Normal file
31
loader/src/ids/CCTextInputNode.cpp
Normal file
|
@ -0,0 +1,31 @@
|
|||
#include <Geode/modify/CCTextInputNode.hpp>
|
||||
|
||||
// This doesn't actually add any IDs since those aren't needed for
|
||||
// CCTextInputNode where everything is accessible through members.
|
||||
// This is to fix the effects of the epic mistake of Cocos2d inventing
|
||||
// ignoreAnchorPointForPosition which causes the content size of
|
||||
// text input nodes to be way off
|
||||
|
||||
struct $modify(CCTextInputNode) {
|
||||
bool init(float width, float height, const char* caption, const char* thonburi, int maxCharCount, const char* font) {
|
||||
if (!CCTextInputNode::init(width, height, caption, thonburi, maxCharCount, font))
|
||||
return false;
|
||||
|
||||
this->ignoreAnchorPointForPosition(false);
|
||||
this->fixPosition();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void fixPosition() {
|
||||
if (!m_bIgnoreAnchorPointForPosition && m_placeholderLabel) {
|
||||
this->setAnchorPoint(m_placeholderLabel->getAnchorPoint());
|
||||
m_placeholderLabel->setPosition(m_obContentSize * m_obAnchorPoint);
|
||||
}
|
||||
}
|
||||
|
||||
void updateLabel(gd::string text) {
|
||||
CCTextInputNode::updateLabel(text);
|
||||
this->fixPosition();
|
||||
}
|
||||
};
|
Loading…
Reference in a new issue