add Actor::SetEventDispatchEnabled()
This commit is contained in:
parent
b90642fd15
commit
a224a6361a
|
|
@ -59,6 +59,7 @@ Actor::Actor()
|
|||
, cascade_opacity_(false)
|
||||
, show_border_(false)
|
||||
, is_fast_transform_(true)
|
||||
, evt_dispatch_enabled_(true)
|
||||
, parent_(nullptr)
|
||||
, stage_(nullptr)
|
||||
, hash_name_(0)
|
||||
|
|
@ -191,7 +192,7 @@ bool Actor::CheckVisibility(RenderContext& ctx) const
|
|||
|
||||
bool Actor::DispatchEvent(Event* evt)
|
||||
{
|
||||
if (!visible_)
|
||||
if (!visible_ || !evt_dispatch_enabled_)
|
||||
return true;
|
||||
|
||||
// Dispatch to children those are greater than 0 in Z-Order
|
||||
|
|
@ -220,6 +221,11 @@ bool Actor::DispatchEvent(Event* evt)
|
|||
return true;
|
||||
}
|
||||
|
||||
void Actor::SetEventDispatchEnabled(bool enabled)
|
||||
{
|
||||
evt_dispatch_enabled_ = enabled;
|
||||
}
|
||||
|
||||
void Actor::DoSerialize(Serializer* serializer) const
|
||||
{
|
||||
ObjectBase::DoSerialize(serializer);
|
||||
|
|
|
|||
|
|
@ -105,6 +105,10 @@ public:
|
|||
/// @brief 是否启用级联透明度
|
||||
bool IsCascadeOpacityEnabled() const;
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 是否启用事件分发
|
||||
bool IsEventDispatchEnabled() const;
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 获取名称的 Hash 值
|
||||
size_t GetHashName() const;
|
||||
|
|
@ -408,6 +412,11 @@ public:
|
|||
/// @return 是否继续分发该事件
|
||||
virtual bool DispatchEvent(Event* evt);
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 开启或关闭事件分发功能
|
||||
/// @param enabled 是否开启
|
||||
void SetEventDispatchEnabled(bool enabled);
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 序列化
|
||||
void DoSerialize(Serializer* serializer) const override;
|
||||
|
|
@ -469,6 +478,7 @@ private:
|
|||
bool hover_;
|
||||
bool pressed_;
|
||||
bool responsible_;
|
||||
bool evt_dispatch_enabled_;
|
||||
int z_order_;
|
||||
float opacity_;
|
||||
float displayed_opacity_;
|
||||
|
|
@ -518,6 +528,11 @@ inline bool Actor::IsCascadeOpacityEnabled() const
|
|||
return cascade_opacity_;
|
||||
}
|
||||
|
||||
inline bool Actor::IsEventDispatchEnabled() const
|
||||
{
|
||||
return evt_dispatch_enabled_;
|
||||
}
|
||||
|
||||
inline size_t Actor::GetHashName() const
|
||||
{
|
||||
return hash_name_;
|
||||
|
|
|
|||
Loading…
Reference in New Issue