!40226 Slider的Click事件异常发送处理挑单5.0release

Merge pull request !40226 from FredTT/cherry-pick-1723445948
This commit is contained in:
openharmony_ci 2024-08-13 02:33:34 +00:00 committed by Gitee
commit c6acb4627b
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 16 additions and 3 deletions

View File

@ -36,20 +36,29 @@ public:
void FireChangeEvent(float value, int32_t mode)
{
constexpr int32_t BEGIN_MODE = 0;
constexpr int32_t END_MODE = 2;
if (mode == END_MODE) {
inAction_ = false;
}
if (mode == BEGIN_MODE) {
inAction_ = true;
}
if (onChangeEvent_) {
onChangeEvent_(value);
}
constexpr int32_t BEGIN_MODE = 0;
CHECK_NULL_VOID(changeEvent_);
changeEvent_(value, mode);
if (mode > BEGIN_MODE) {
SetValue(value);
value_ = value;
}
}
void SetValue(float value)
{
value_ = value;
if (!inAction_) {
value_ = value;
}
}
float GetValue() const
@ -63,6 +72,7 @@ public:
}
private:
bool inAction_ = false;
SliderOnChangeEvent changeEvent_;
SliderOnValueChangeEvent onChangeEvent_;
float value_ = .0f;

View File

@ -54,6 +54,9 @@ void SliderModelNG::SetSliderValue(float value)
auto pattern = frameNode->GetPattern<SliderPattern>();
CHECK_NULL_VOID(pattern);
pattern->UpdateValue(value);
auto sliderEventHub = frameNode->GetEventHub<SliderEventHub>();
CHECK_NULL_VOID(sliderEventHub);
sliderEventHub->SetValue(value);
}
void SliderModelNG::SetSliderMode(const SliderMode& value)
{