mercredi 9 décembre 2015

C# Events / Block when hit GUI

I'm working on a custom GUI with SharpDX.

I have user Input from a Form Object and assign Action Methods to the specific events. Below my UI I have a "drawing canvas" and I use Tool Objects that also listen to those Form Events.

But I'm a bit stuck on the matter of how to design my program to only pass those events to a second layer (in this case my canvas) when the first layer did not "hit" anything. In short: Only call "Tool.OnMouseDown" when "Button.OnMouseDown" did return false? Would a Chain Of Responsibility be the/a correct or possible approach?

Or shall I make the current Tool check if "Excecute (Vector2)" is above some gui element but I think this would lead to the kind of coupling I want to prevent.

Hope someone is willing to help/hint (sorry for no code examples, if it's to confusingly descriped please tell me ;))

Thanks!

(Disclaimer: I know I don't have to reinvent the wheel, but I use it partly to learn and improve on my design patterns and coding skills)

Aucun commentaire:

Enregistrer un commentaire