Skip to content

Commit 22de798

Browse files
authored
Fix UI Mistakes in Release/2.10.0 (#3161)
* Refactor onWindowSizeChanged to use event data Updated onWindowSizeChanged to accept an event parameter and directly retrieve the new window size, because old function only got old size * Fix control assignment in touch listener Update touch listener control assignment to use _renderLabel if control is null. * Update onWindowSizeChanged to accept EventCustom * Remove useless comments and change reference into copying value In this case, copying value might run faster than using reference because memory jump would occur when using reference.
1 parent 5e37bca commit 22de798

3 files changed

Lines changed: 15 additions & 7 deletions

File tree

core/ui/UITextFieldEx.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,9 @@ void TextFieldEx::enableIME(Node* control)
367367
}
368368
_touchListener = EventListenerTouchOneByOne::create();
369369

370-
if (control == nullptr)
371-
control = this;
370+
// this->getContentSize() == Vec2::ZERO, so we need to use the size of _renderLabel;
371+
if(control == nullptr)
372+
control = this->_renderLabel;
372373

373374
_touchListener->onTouchBegan = [control,this](Touch* touch, Event*) {
374375
bool focus = (_checkVisibility(this) && _editable && this->_enabled &&

extensions/fairygui/src/fairygui/GRoot.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -561,18 +561,25 @@ bool GRoot::initWithScene(ax::Scene* scene, int zOrder)
561561
_inputProcessor->setCaptureCallback(AX_CALLBACK_1(GRoot::onTouchEvent, this));
562562

563563
#if defined(AX_PLATFORM_PC) && AX_TARGET_PLATFORM != AX_PLATFORM_WINRT
564-
_windowSizeListener = Director::getInstance()->getEventDispatcher()->addCustomEventListener(RenderViewImpl::EVENT_WINDOW_RESIZED, AX_CALLBACK_0(GRoot::onWindowSizeChanged, this));
564+
_windowSizeListener = Director::getInstance()->getEventDispatcher()->addCustomEventListener(RenderViewImpl::EVENT_WINDOW_RESIZED, AX_CALLBACK_1(GRoot::onWindowSizeChanged, this));
565565
#endif
566-
onWindowSizeChanged();
566+
567+
/*onWindowSizeChanged*/{
568+
const ax::Size& rs = Director::getInstance()->getRenderView()->getDesignResolutionSize();
569+
setSize(rs.width, rs.height);
570+
571+
// updateContentScaleLevel();
572+
}
573+
567574

568575
scene->addChild(_displayObject, zOrder);
569576

570577
return true;
571578
}
572579

573-
void GRoot::onWindowSizeChanged()
580+
void GRoot::onWindowSizeChanged(ax::EventCustom* e)
574581
{
575-
const ax::Size& rs = Director::getInstance()->getRenderView()->getDesignResolutionSize();
582+
const ax::Size rs = *static_cast<ax::Size*>(e->getUserData());
576583
setSize(rs.width, rs.height);
577584

578585
updateContentScaleLevel();

extensions/fairygui/src/fairygui/GRoot.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class GRoot : public GComponent
7171

7272
private:
7373
bool initWithScene(ax::Scene* scene, int zOrder);
74-
void onWindowSizeChanged();
74+
void onWindowSizeChanged(ax::EventCustom* e);
7575
void createModalLayer();
7676
void adjustModalLayer();
7777
void closePopup(GObject* target);

0 commit comments

Comments
 (0)