MCPcopy Create free account
hub / github.com/axmolengine/axmol / enableIME

Method enableIME

core/ui/UITextFieldEx.cpp:362–446  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

360}
361
362void TextFieldEx::enableIME(Node* control)
363{
364 if (_touchListener != nullptr)
365 {
366 return;
367 }
368 _touchListener = EventListenerTouchOneByOne::create();
369
370 // this->getContentSize() == Vec2::ZERO, so we need to use the size of _renderLabel;
371 if(control == nullptr)
372 control = this->_renderLabel;
373
374 _touchListener->onTouchBegan = [control,this](Touch* touch, Event*) {
375 bool focus = (_checkVisibility(this) && _editable && this->_enabled &&
376 _containsTouchPoint(control, touch));
377
378 if (this->_continuousTouchDelayTimerID != nullptr)
379 {
380 stimer::kill(this->_continuousTouchDelayTimerID);
381 this->_continuousTouchDelayTimerID = nullptr;
382 }
383
384 if (focus && _cursorVisible)
385 {
386 auto worldPoint = touch->getLocation();
387 if (this->_continuousTouchCallback)
388 {
389 this->_continuousTouchDelayTimerID = stimer::delay(
390 this->_continuousTouchDelayTime, [=, this]() { this->_continuousTouchCallback(worldPoint); });
391 }
392 }
393 return true;
394 };
395 _touchListener->onTouchEnded = [control, this](Touch* touch, Event* e) {
396 if (this->_continuousTouchDelayTimerID != nullptr)
397 {
398 stimer::kill(this->_continuousTouchDelayTimerID);
399 this->_continuousTouchDelayTimerID = nullptr;
400 }
401
402 bool focus = (_checkVisibility(this) && _editable && this->_enabled &&
403 _containsTouchPoint(control, touch));
404
405 if (focus)
406 {
407 if (!s_keyboardVisible || !_cursorVisible)
408 openIME();
409 if (_touchCursorControlEnabled)
410 {
411 auto renderLabelPoint = _renderLabel->convertToNodeSpace(touch->getLocation());
412 __moveCursorTo(renderLabelPoint.x);
413 }
414 }
415 else
416 {
417 closeIME();
418 }
419 };

Callers 1

Calls 9

__moveCursorMethod · 0.95
handleDeleteKeyEventMethod · 0.95
createFunction · 0.85
_checkVisibilityFunction · 0.85
_containsTouchPointFunction · 0.85
delayFunction · 0.85
convertToNodeSpaceMethod · 0.80
getLocationMethod · 0.45

Tested by

no test coverage detected