fix menu in preview

Signed-off-by: liujinwei <hw.liujinwei@huawei.com>
Change-Id: I42c89ee24216de6d4ba24818ca0211e0f67d5f64
This commit is contained in:
liujinwei
2022-03-19 11:24:46 +08:00
parent d51ee98f32
commit ca4da86142
3 changed files with 33 additions and 0 deletions
+5
View File
@@ -65,6 +65,7 @@ pa_engine_path = "adapter/ohos/entrance/pa_engine"
enable_rosen_backend = true
enable_standard_input = true
build_container_scope_lib = true
multiple_window_support = true
if (defined(is_experiment_build) && is_experiment_build) {
web_components_support = true
@@ -104,6 +105,10 @@ if (enable_standard_input) {
defines += [ "ENABLE_STANDARD_INPUT" ]
}
if (multiple_window_support) {
defines += [ "MULTIPLE_WINDOW_SUPPORTED" ]
}
cflags_cc = [
"-Wno-thread-safety-attributes",
"-Wno-thread-safety-analysis",
@@ -3524,7 +3524,9 @@ void JSViewAbstract::JsBindContextMenu(const JSCallbackInfo& info)
if (!menuComponent) {
return;
}
#if defined(MULTIPLE_WINDOW_SUPPORTED)
menuComponent->SetIsContextMenu(true);
#endif
int32_t responseType = static_cast<int32_t>(ResponseType::LONGPRESS);
if (info.Length() == 2 && info[1]->IsNumber()) {
responseType = info[1]->ToNumber<int32_t>();
@@ -3540,7 +3542,11 @@ void JSViewAbstract::JsBindContextMenu(const JSCallbackInfo& info)
}
if (info.GetButton() == MouseButton::RIGHT_BUTTON && info.GetAction() == MouseAction::RELEASE) {
auto showMenu = refPtr->GetTargetCallback();
#if defined(MULTIPLE_WINDOW_SUPPORTED)
showMenu("", info.GetScreenLocation());
#else
showMenu("", info.GetGlobalLocation());
#endif
}
});
} else if (responseType == static_cast<int32_t>(ResponseType::LONGPRESS)) {
@@ -3553,7 +3559,11 @@ void JSViewAbstract::JsBindContextMenu(const JSCallbackInfo& info)
return;
}
auto showMenu = refPtr->GetTargetCallback();
#if defined(MULTIPLE_WINDOW_SUPPORTED)
showMenu("", info.GetScreenLocation());
#else
showMenu("", info.GetGlobalLocation());
#endif
});
box->SetOnLongPress(longGesture);
} else {
@@ -23,7 +23,25 @@ namespace OHOS::Ace::Framework {
void JSContextMenu::Close(const JSCallbackInfo& args)
{
#if defined(MULTIPLE_WINDOW_SUPPORTED)
SubwindowManager::GetInstance()->CloseMenu();
#else
// Close context menu.
auto container = Container::Current();
if (container) {
auto context = container->GetPipelineContext();
auto executor = Container::CurrentTaskExecutor();
if (executor) {
executor->PostTask(
[context]() {
if (context) {
context->CloseContextMenu();
}
},
TaskExecutor::TaskType::UI);
}
}
#endif
args.SetReturnValue(args.This());
}