@@ -172,13 +172,42 @@ type FpsDispatcher () =
172172type PanelDispatcher () =
173173 inherit GuiDispatcher ()
174174
175+ static let handlePanelLeftDown evt world =
176+ let entity = evt.Subscriber : Entity
177+ if entity.GetVisible world then
178+ let mutable transform = entity.GetTransform world
179+ let perimeter = transform.Perimeter.Box2 // gui currently ignores rotation
180+ let mousePositionWorld = World.getMousePosition2dWorld transform.Absolute world
181+ if perimeter.Intersects mousePositionWorld then Resolve
182+ else Cascade
183+ else Cascade
184+
185+ static let handlePanelLeftUp evt world =
186+ let entity = evt.Subscriber : Entity
187+ let wasDown = entity.GetDown world
188+ entity.SetDown false world
189+ entity.TrySet ( nameof Entity.TextOffset) v2Zero world |> ignore
190+ if entity.GetVisible world then
191+ let mutable transform = entity.GetTransform world
192+ let perimeter = transform.Perimeter.Box2 // gui currently ignores rotation
193+ let mousePositionWorld = World.getMousePosition2dWorld transform.Absolute world
194+ if perimeter.Intersects mousePositionWorld then
195+ if transform.Enabled && wasDown then Resolve
196+ else Cascade
197+ else Cascade
198+ else Cascade
199+
175200 static member Facets =
176201 [ typeof< BackdroppableFacet>]
177202
178203 static member Properties =
179204 [ define Entity.Size ( v3 Constants.Engine.EntityGuiSizeDefault.X Constants.Engine.EntityGuiSizeDefault.X 0.0 f)
180205 define Entity.BackdropImageOpt ( Some Assets.Default.Panel)]
181206
207+ override this.Register ( entity , world ) =
208+ World.monitor handlePanelLeftDown Nu.Game.Handle.MouseLeftDownEvent entity world
209+ World.monitor handlePanelLeftUp Nu.Game.Handle.MouseLeftUpEvent entity world
210+
182211/// Gives an entity the base behavior of basic static sprite emitter.
183212type BasicStaticSpriteEmitterDispatcher () =
184213 inherit Entity2dDispatcher ( true , false , false )
0 commit comments