Class HoverStateBehavior<TValue>
Definition
Namespace: StardewUI.Framework.Behaviors
Assembly: StardewUI.dll
Behavior that applies a property override when a view enters a hover state.
Type Parameters
TValue
Value type for the overridden property.
Inheritance
Object ⇦ ViewBehavior<TView, TData> ⇦ HoverStateBehavior<TValue>
Remarks
The override is added on pointer enter (i.e. when initiating hover) and removed on pointer leave.
Members
Constructors
Name | Description |
---|---|
HoverStateBehavior<TValue>(string) | Behavior that applies a property override when a view enters a hover state. |
Properties
Name | Description |
---|---|
Data | The assigned or bound data. (Inherited from ViewBehavior<TView, TData>) |
View | The currently-attached view. (Inherited from ViewBehavior<TView, TData>) |
ViewState | State overrides for the View. (Inherited from ViewBehavior<TView, TData>) |
Methods
Name | Description |
---|---|
CanUpdate() | Checks whether the behavior is allowed to Update(TimeSpan). (Inherited from ViewBehavior<TView, TData>) |
Dispose() | (Inherited from ViewBehavior<TView, TData>) |
Initialize(BehaviorTarget) | Initializes the target (view, state overrides, etc.) for the behavior. (Inherited from ViewBehavior<TView, TData>) |
OnAttached() | Runs after the behavior is attached to a target. (Overrides ViewBehavior<TView, TData>.OnAttached()) |
OnDetached(IView) | Runs when the behavior is detached from a target. (Overrides ViewBehavior<TView, TData>.OnDetached(IView)) |
OnDispose() | Runs when the behavior is being disposed. (Inherited from ViewBehavior<TView, TData>) |
OnNewData(TValue) | (Overrides ViewBehavior<TView, TData>.OnNewData(TData)) |
PreUpdate(TimeSpan) | Runs on every update tick, before any bindings or views update. (Inherited from ViewBehavior<TView, TData>) |
Update(TimeSpan) | Runs on every update tick. (Overrides ViewBehavior<TView, TData>.Update(TimeSpan)) |
Details
Constructors
HoverStateBehavior<TValue>(string)
Behavior that applies a property override when a view enters a hover state.
Parameters
propertyName
string
Name of the overridden property.
Remarks
The override is added on pointer enter (i.e. when initiating hover) and removed on pointer leave.
Methods
OnAttached()
Runs after the behavior is attached to a target.
Remarks
Setup code should go in this method to ensure that the values of View and ViewState are actually assigned. If code runs in the behavior's constructor, these are not guaranteed to be populated.
OnDetached(IView)
Runs when the behavior is detached from a target.
Parameters
view
IView
The view that was previously attached.
Remarks
Behaviors may receive new views as part of a "rebind", if the old view is destroyed and recreated, for example as the result of a conditional binding changing states.
OnDetached
is always immediately followed by OnAttached(). A behavior cannot remain in a detached state; however, overriding this method gives behaviors the opportunity to clean up state from the old view (e.g. remove event handlers) before the new one is attached.
Also runs when the behavior is disposed, so detach logic does not need to be duplicated in OnDispose().
OnNewData(TValue)
Parameters
previousData
TValue
Update(TimeSpan)
Runs on every update tick.
Parameters
elapsed
TimeSpan
Time elapsed since the last update.