mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-23 07:01:24 +00:00
修改系统键盘切换自定义键盘的避让问题
Signed-off-by: lixiang <lixiang380@huawei.com>
This commit is contained in:
parent
18f15104a8
commit
1e7efaf106
@ -125,7 +125,7 @@ void RenderWeb::RegistVirtualKeyBoardListener()
|
||||
return;
|
||||
}
|
||||
pipelineContext->SetVirtualKeyBoardCallback(
|
||||
[weak = AceType::WeakClaim(this)](int32_t width, int32_t height, double keyboard) {
|
||||
[weak = AceType::WeakClaim(this)](int32_t width, int32_t height, double keyboard, bool isCustomKeyboard) {
|
||||
auto renderWeb = weak.Upgrade();
|
||||
if (renderWeb) {
|
||||
return renderWeb->ProcessVirtualKeyBoard(width, height, keyboard);
|
||||
|
@ -2937,10 +2937,10 @@ void WebPattern::RegistVirtualKeyBoardListener(const RefPtr<PipelineContext> &pi
|
||||
return;
|
||||
}
|
||||
pipelineContext->SetVirtualKeyBoardCallback(GetHost()->GetId(),
|
||||
[weak = AceType::WeakClaim(this)](int32_t width, int32_t height, double keyboard) {
|
||||
[weak = AceType::WeakClaim(this)](int32_t width, int32_t height, double keyboard, bool isCustomKeyboard) {
|
||||
auto webPattern = weak.Upgrade();
|
||||
CHECK_NULL_RETURN(webPattern, false);
|
||||
return webPattern->ProcessVirtualKeyBoard(width, height, keyboard);
|
||||
return webPattern->ProcessVirtualKeyBoard(width, height, keyboard, isCustomKeyboard);
|
||||
});
|
||||
needUpdateWeb_ = false;
|
||||
}
|
||||
@ -3303,8 +3303,15 @@ bool WebPattern::ProcessVirtualKeyBoardShow(int32_t width, int32_t height, doubl
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WebPattern::ProcessVirtualKeyBoard(int32_t width, int32_t height, double keyboard)
|
||||
bool WebPattern::ProcessVirtualKeyBoard(int32_t width, int32_t height, double keyboard, bool isCustomKeyboard)
|
||||
{
|
||||
if (isUsingCustomKeyboardAvoid_) {
|
||||
if (!isCustomKeyboard) {
|
||||
// if use custom keyboard, no need to handle the system keyboard event.
|
||||
TAG_LOGI(AceLogTag::ACE_WEB, "ProcessVirtualKeyBoard no need to handle the system keyboard event.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
CHECK_NULL_RETURN(delegate_, false);
|
||||
delegate_->SetVirtualKeyBoardArg(width, height, keyboard);
|
||||
|
||||
@ -4971,6 +4978,7 @@ void WebPattern::AttachCustomKeyboard()
|
||||
overlayManager->BindKeyboard(customKeyboardBuilder_, frameNode->GetId());
|
||||
keyboardOverlay_ = overlayManager;
|
||||
keyboardOverlay_->AvoidCustomKeyboard(frameNode->GetId(), 0);
|
||||
isUsingCustomKeyboardAvoid_ = true;
|
||||
TAG_LOGI(AceLogTag::ACE_WEB, "WebCustomKeyboard AttachCustomKeyboard end");
|
||||
}
|
||||
|
||||
@ -4981,6 +4989,7 @@ void WebPattern::CloseCustomKeyboard()
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
CHECK_NULL_VOID(keyboardOverlay_);
|
||||
keyboardOverlay_->CloseKeyboard(frameNode->GetId());
|
||||
isUsingCustomKeyboardAvoid_ = false;
|
||||
TAG_LOGI(AceLogTag::ACE_WEB, "WebCustomKeyboard CloseCustomKeyboard end");
|
||||
}
|
||||
|
||||
|
@ -747,7 +747,7 @@ private:
|
||||
bool IsNeedResizeVisibleViewport();
|
||||
bool ProcessVirtualKeyBoardHide(int32_t width, int32_t height, bool safeAreaEnabled);
|
||||
bool ProcessVirtualKeyBoardShow(int32_t width, int32_t height, double keyboard, bool safeAreaEnabled);
|
||||
bool ProcessVirtualKeyBoard(int32_t width, int32_t height, double keyboard);
|
||||
bool ProcessVirtualKeyBoard(int32_t width, int32_t height, double keyboard, bool isCustomKeyboard = false);
|
||||
void UpdateWebLayoutSize(int32_t width, int32_t height, bool isKeyboard, bool isUpdate = true);
|
||||
void UpdateLayoutAfterKeyboardShow(int32_t width, int32_t height, double keyboard, double oldWebHeight);
|
||||
bool OnDirtyLayoutWrapperSwap(const RefPtr<LayoutWrapper>& dirty, const DirtySwapConfig& config) override;
|
||||
@ -1193,7 +1193,7 @@ private:
|
||||
OHOS::NWeb::CursorType cursor_type_ = OHOS::NWeb::CursorType::CT_NONE;
|
||||
float touchPointX = 0;
|
||||
float touchPointY = 0;
|
||||
bool isAIEngineInit = false;
|
||||
bool isUsingCustomKeyboardAvoid_ = false;
|
||||
|
||||
protected:
|
||||
OnCreateMenuCallback onCreateMenuCallback_;
|
||||
|
@ -763,7 +763,7 @@ void PipelineBase::OnVirtualKeyboardAreaChange(Rect keyboardArea,
|
||||
#endif
|
||||
}
|
||||
double keyboardHeight = keyboardArea.Height();
|
||||
if (NotifyVirtualKeyBoard(rootWidth_, rootHeight_, keyboardHeight)) {
|
||||
if (NotifyVirtualKeyBoard(rootWidth_, rootHeight_, keyboardHeight, true)) {
|
||||
return;
|
||||
}
|
||||
OnVirtualKeyboardHeightChange(keyboardHeight, rsTransaction, safeHeight, supportAvoidance, forceChange);
|
||||
@ -783,7 +783,7 @@ void PipelineBase::OnVirtualKeyboardAreaChange(Rect keyboardArea, double positio
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (NotifyVirtualKeyBoard(rootWidth_, rootHeight_, keyboardHeight)) {
|
||||
if (NotifyVirtualKeyBoard(rootWidth_, rootHeight_, keyboardHeight, false)) {
|
||||
return;
|
||||
}
|
||||
OnVirtualKeyboardHeightChange(keyboardHeight, positionY, height, rsTransaction, forceChange);
|
||||
|
@ -960,7 +960,7 @@ public:
|
||||
|
||||
void OnFoldDisplayModeChanged(FoldDisplayMode foldDisplayMode);
|
||||
|
||||
using virtualKeyBoardCallback = std::function<bool(int32_t, int32_t, double)>;
|
||||
using virtualKeyBoardCallback = std::function<bool(int32_t, int32_t, double, bool)>;
|
||||
void SetVirtualKeyBoardCallback(virtualKeyBoardCallback&& listener)
|
||||
{
|
||||
static std::atomic<int32_t> pseudoId(-1); // -1 will not be conflict with real node ids.
|
||||
@ -975,11 +975,11 @@ public:
|
||||
{
|
||||
virtualKeyBoardCallback_.erase(nodeId);
|
||||
}
|
||||
bool NotifyVirtualKeyBoard(int32_t width, int32_t height, double keyboard) const
|
||||
bool NotifyVirtualKeyBoard(int32_t width, int32_t height, double keyboard, bool isCustomKeyboard) const
|
||||
{
|
||||
bool isConsume = false;
|
||||
for (const auto& [nodeId, iterVirtualKeyBoardCallback] : virtualKeyBoardCallback_) {
|
||||
if (iterVirtualKeyBoardCallback && iterVirtualKeyBoardCallback(width, height, keyboard)) {
|
||||
if (iterVirtualKeyBoardCallback && iterVirtualKeyBoardCallback(width, height, keyboard, isCustomKeyboard)) {
|
||||
isConsume = true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user