ApplicationCommandManager question

Hi all,
I read something in the documentation but am not quite sure I understand it correctly. Could someone please show me on an example when is the ApplicationCommandManager useful? I can use Listeners for the same thing, can’t I?

(sorry if this is a really dumb question…)

Thanks in advance.
Y.

It’s useful, honestly. Otherwise I wouldn’t have wasted so much time writing it!

It makes it easy to route commands to the appropriate targets, e.g. a “copy” command might be mapped to one key-press, but would go to different targets depending on which UI component is focused. It also means you can use the same mechanism to trigger commands by key-presses, buttons, menus, or other things.

Sure you could do everything with low-level listeners, but in a medium-sized app you’ll find that quickly becomes very messy.

[quote=“jules”]It’s useful, honestly. Otherwise I wouldn’t have wasted so much time writing it!
[/quote]
:lol: Yeah exactly, I saw it was pretty complicated and I somehow “knew” it must be useful although I couldn’t quite grasp how…

So it works that the ACM sends message to the first ApplicationCommandTarget which then issues commands through its perform() method. If it can’t handle it it, the getNextCommandTarget() determines who is the next to try it.

Do I get this right? Or am I still missing something?
Thanks.
Y.

Yeah, that’s pretty much how it works. It’s hard to explain, but makes sense when you use it.

Thanks, I will try to get more into it in practical application :slight_smile:
Y.