Commands broadcasts upstream only?

Topics: CAB & Smart Client Software Factory
Dec 2, 2006 at 11:09 AM
originally posted by: SkySigal2

I've just been playing with nested WorkItems, and commands.

What I am noticing (and !please! correct me if this is not the case)
that if I register a UIElement menuItem using the workitem of the nested WorkItem (eg: Calendar) the Calendar controller receives it.

But if I register the UIElement menuItem using the workItem of the ROOT workitem, it doesn't.

Fair enough, you say, use the WorkItem of the View that needs the functionality...

Yes, but, what about Menu Items that need to be globally issued? Eg: Cut/Copy/Paste, which should be heard by all, but only reacted to by the active View? Or a WorkOffline menu element that was created by the Shell, but that all modules should maybe listen for?

Or I am not getting the big picture (yet again :-) ) and there's another way to solve this?

Again, thanks for any pointers.
Dec 2, 2006 at 3:50 PM
originally posted by: ChrisHolmes

The order of creation is the only important thing here. A toolstripitem added to a UIExtensionSite must be added before any CommandHandlers get registered for it. Otherwise, those CommandHandlers (created before the button itself) won't react when the button is clicked. It's all about the wire-up of these items in the CAB loading process.

So, for instance, imagine you had this hierarchy of WorkItems:

Root --> WorkItemA --> WorkItemB

If you create a button in WorkItemA and register it with the UIExtensionSite, then create a CommandHandler in WorkItemB, the CommandHandler will react when the button is clicked.

But suppose you create a CommandHandler in Root as well. It will not fire, because the button isn't actually created until the WorkItemA is created and registered with the UIExtensionSite.

"Yes, but, what about Menu Items that need to be globally issued?"

Create those toolstripitems at the highest level then. If you think every module will use them, then create them and register them at the Root level and leave it up to the subsequent Workitems to create CommandHandlers for them.

Also, I know it is tedious because these boards don't have a great search mechanism, but the Cut/Copy/Paste problem has cropped up quite a bit and several people have postes their solutions. So if you need that specific problem solved, I'd say dig in and surf the boards :=)
Dec 2, 2006 at 4:23 PM
originally posted by: SkySigal2

Thanks! Knowing that its Order based makes it easier to untangle and find an acceptable solution.

PS: Mea Culpa...I'll use the search more next time
Dec 2, 2006 at 4:37 PM
originally posted by: SkySigal2

I'm going to guess that Pub/Sub of Events is also order based.

It would make sense (can't do a "+= eventhandler" to an event that hasn't been defined yet...)...

Thanks again.