fix not show keyboard for quick note

Signed-off-by: hukai86 <mail.hk@163.com>
This commit is contained in:
hukai86 2023-07-27 16:58:44 +08:00
parent ea6e6e184d
commit f347fbb859
4 changed files with 28 additions and 3 deletions

View File

@ -136,8 +136,6 @@ public:
virtual void OnSetDepth(const int32_t depth) {}
virtual void OnSetDepth(const int32_t depth) {}
// DFX info.
void DumpTree(int32_t depth);

View File

@ -88,6 +88,9 @@ void AbilityComponentPattern::FireConnect()
{
hasConnectionToAbility_ = true;
UpdateWindowRect();
auto pipeline = PipelineBase::GetCurrentContext();
TransferFocusWindowId(pipeline->GetFocusWindowId());
TransferFocusState(IsCurrentFocus());
auto abilityComponentEventHub = GetEventHub<AbilityComponentEventHub>();
CHECK_NULL_VOID(abilityComponentEventHub);
@ -193,6 +196,9 @@ void AbilityComponentPattern::HandleTouchEvent(const TouchEventInfo& info)
auto scale = host->GetTransformScale();
Platform::CalculatePointerEvent(selfGlobalOffset, pointerEvent, scale);
WindowPattern::DispatchPointerEvent(pointerEvent);
auto hub = host->GetFocusHub();
CHECK_NULL_VOID(hub);
hub->RequestFocusImmediately();
}
void AbilityComponentPattern::HandleMouseEvent(const MouseInfo& info)
@ -201,12 +207,17 @@ void AbilityComponentPattern::HandleMouseEvent(const MouseInfo& info)
return;
}
const auto pointerEvent = info.GetPointerEvent();
CHECK_NULL_VOID(pointerEvent);
CHECK_NULL_VOID_NOLOG(pointerEvent);
auto host = GetHost();
CHECK_NULL_VOID_NOLOG(host);
auto selfGlobalOffset = host->GetTransformRelativeOffset();
auto scale = host->GetTransformScale();
Platform::CalculatePointerEvent(selfGlobalOffset, pointerEvent, scale);
if (info.GetAction() == MouseAction::PRESS) {
auto hub = host->GetFocusHub();
CHECK_NULL_VOID(hub);
hub->RequestFocusImmediately();
}
WindowPattern::DispatchPointerEvent(pointerEvent);
}
@ -256,11 +267,13 @@ void AbilityComponentPattern::HandleFocusEvent()
if (pipeline->GetIsFocusActive()) {
WindowPattern::DisPatchFocusActiveEvent(true);
}
TransferFocusState(true);
}
void AbilityComponentPattern::HandleBlurEvent()
{
WindowPattern::DisPatchFocusActiveEvent(false);
TransferFocusState(false);
}
bool AbilityComponentPattern::KeyEventConsumed(const KeyEvent& event)
@ -281,4 +294,13 @@ bool AbilityComponentPattern::OnKeyEvent(const KeyEvent& event)
return KeyEventConsumed(event);
}
}
bool AbilityComponentPattern::IsCurrentFocus() const
{
auto host = GetHost();
CHECK_NULL_RETURN_NOLOG(host, false);
auto focusHub = host->GetFocusHub();
CHECK_NULL_RETURN_NOLOG(focusHub, false);
return focusHub->IsCurrentFocus();
}
} // namespace OHOS::Ace::NG

View File

@ -122,6 +122,7 @@ private:
}
void UpdateWindowRect();
bool IsCurrentFocus() const;
bool isActive_ = false;
bool hasConnectionToAbility_ = false;

View File

@ -48,4 +48,8 @@ void WindowPattern::DispatchKeyEventForConsumed(const std::shared_ptr<MMI::KeyEv
void WindowPattern::DisPatchFocusActiveEvent(bool isFocusActive) {}
void WindowPattern::OnModifyDone() {}
void WindowPattern::TransferFocusWindowId(uint32_t focusWindowId) {}
void WindowPattern::TransferFocusState(bool focusState) {}
} // namespace OHOS::Ace::NG