ApplicationCommand only works when target has focus?


#1

I have a component that inherits from ApplicationCommandTarget and i can trigger it’s commands just fine, but only when it has focus. When it does not have focus it does not get triggered. Is there anything i can do to make sure it will trigger without having focus?


#2

There are good reasons why it works like that. If you have a command that is global, then it shouldn’t belong to a subcomponent - you should either use a global command target for it, or make your top-level component the command target so it always gets used as a last resort.


#3

Yes I thought about putting the command in the main component but all the action takes place in the component that is nested about 4 components deeper.

I guess making all subcomponents public is not an option. But writing methods in 3 components just to access the deeply nested component seems a bit messy. Any advise on the best approach?


#4

If there’s something global that you need to be able to access from any part of your app, then it should be a global object, not a subcomponent that may or may not be there.

Perhaps the fact that this is causing problems might be because your design needs re-thinking… maybe using more of a model/view architecture would help?


#5

We have have a good separation of engine and interface so in a sense it is a model/view/controller design.

It,s not that we have to access a nested component from anywhere, we just need to make something happen in the interface to a deeply nested component that does not always have focus. I,m sorry if there is no one sentence answer to this.


#6

Ok, well I suppose you could add methods to each of the enclosing parent components that let you find this subcomponent, so that you just can call the top-level method to find it when you need it. That’s not too messy.


#7