mirror of
https://github.com/openharmony/ace_ace_engine.git
synced 2026-07-19 14:43:36 -04:00
fix bug of indexer and button
Signed-off-by: luoying_ace_admin <luoying19@huawei.com>
This commit is contained in:
@@ -31,36 +31,36 @@ const std::vector<V2::AlignStyle> ALIGN_STYLE = { V2::AlignStyle::LEFT, V2::Alig
|
||||
void JSIndexer::Create(const JSCallbackInfo& args)
|
||||
{
|
||||
if (args.Length() >= 1 && args[0]->IsObject()) {
|
||||
JSRef<JSObject> obj = JSRef<JSObject>::Cast(args[0]);
|
||||
auto param = JsonUtil::ParseJsonString(args[0]->ToString());
|
||||
if (!param || param->IsNull()) {
|
||||
LOGE("JSIndexer::Create param is null");
|
||||
return;
|
||||
}
|
||||
std::vector<std::string> indexerArray;
|
||||
|
||||
JSRef<JSVal> arrayVal = obj->GetProperty("arrayValue");
|
||||
if (!arrayVal->IsArray()) {
|
||||
auto arrayVal = param->GetValue("arrayValue");
|
||||
if (!arrayVal || !arrayVal->IsArray()) {
|
||||
LOGW("info is invalid");
|
||||
return;
|
||||
}
|
||||
|
||||
JSRef<JSArray> array = JSRef<JSArray>::Cast(arrayVal);
|
||||
int32_t length = static_cast<int32_t>(array->Length());
|
||||
size_t length = static_cast<uint32_t>(arrayVal->GetArraySize());
|
||||
if (length <= 0) {
|
||||
LOGE("info is invalid");
|
||||
return;
|
||||
}
|
||||
for (int32_t i = 0; i < length; i++) {
|
||||
JSRef<JSVal> value = array->GetValueAt(i);
|
||||
std::string tmp;
|
||||
if (ParseJsString(value, tmp)) {
|
||||
indexerArray.emplace_back(tmp);
|
||||
for (size_t i = 0; i < length; i++) {
|
||||
auto value = arrayVal->GetArrayItem(i);
|
||||
if (!value) {
|
||||
return;
|
||||
}
|
||||
indexerArray.emplace_back(value->GetString());
|
||||
}
|
||||
|
||||
JSRef<JSVal> selectedVal = obj->GetProperty("selected");
|
||||
if (!selectedVal->IsNumber()) {
|
||||
LOGE("info is invalid");
|
||||
return;
|
||||
}
|
||||
auto selectedVal = param->GetInt("selected", 0);
|
||||
|
||||
auto indexerComponent =
|
||||
AceType::MakeRefPtr<V2::IndexerComponent>(indexerArray, selectedVal->ToNumber<int32_t>());
|
||||
AceType::MakeRefPtr<V2::IndexerComponent>(indexerArray, selectedVal);
|
||||
ViewStackProcessor::GetInstance()->Push(indexerComponent);
|
||||
JSInteractableView::SetFocusNode(true);
|
||||
args.ReturnSelf();
|
||||
|
||||
@@ -324,7 +324,7 @@ void RenderButton::OnMouseHoverEnterTest()
|
||||
return;
|
||||
}
|
||||
ButtonType type = buttonComponent_->GetType();
|
||||
if (isPhone_ && ((type == ButtonType::TEXT) || (type == ButtonType::NORMAL))) {
|
||||
if ((isPhone_ || isTablet_) && ((type == ButtonType::TEXT) || (type == ButtonType::NORMAL))) {
|
||||
needHoverColor_ = true;
|
||||
MarkNeedRender();
|
||||
} else {
|
||||
@@ -457,6 +457,7 @@ void RenderButton::Update(const RefPtr<Component>& component)
|
||||
isWatch_ = (SystemProperties::GetDeviceType() == DeviceType::WATCH);
|
||||
isTv_ = (SystemProperties::GetDeviceType() == DeviceType::TV);
|
||||
isPhone_ = (SystemProperties::GetDeviceType() == DeviceType::PHONE);
|
||||
isTablet_ = (SystemProperties::GetDeviceType() == DeviceType::TABLET);
|
||||
auto catchMode =
|
||||
buttonComponent_->GetClickedEventId().IsEmpty() || buttonComponent_->GetClickedEventId().GetCatchMode();
|
||||
static const int32_t bubbleModeVersion = 6;
|
||||
|
||||
@@ -178,6 +178,7 @@ protected:
|
||||
bool isWatch_ = false;
|
||||
bool isTv_ = false;
|
||||
bool isPhone_ = false;
|
||||
bool isTablet_ = false;
|
||||
bool widthDefined_ = false;
|
||||
bool heightDefined_ = false;
|
||||
bool progressDisplay_ = false;
|
||||
|
||||
@@ -31,6 +31,14 @@ public:
|
||||
bool OnKeyEvent(const KeyEvent& keyEvent) override;
|
||||
bool IndexMoveUp();
|
||||
bool IndexMoveDown();
|
||||
bool CanUpdate(const RefPtr<Component>& newComponent) override
|
||||
{
|
||||
auto context = context_.Upgrade();
|
||||
if (context && context->GetIsDeclarative()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
WeakPtr<RenderIndexerItem> prevFocusedItem_;
|
||||
|
||||
Reference in New Issue
Block a user