know which signal execute the command
Hello everybody!
Imagine that I map multiple signals to just one command.
Anyone knows how can I know inside the command which signal
executed the command?
Thanks a lot.
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by Ondina D.F. on 02 Nov, 2011 04:36 PM
Hey PA-TH,
There are lots of discussions about signals and commands on this forum.
I’m not sure whether you’ve already seen them or not.
Maybe there is an answer to your question.
Please, let us know if you can’t find anything helpful.
Thank you,
Ondina
2 Posted by Michal Wroblews... on 02 Nov, 2011 08:44 PM
Hi PA-TH,
There are two options for knowing which signal instance dispatched the command. If you're using the simplest Signal you can pass its instance to the command. The other option is to use DeluxeSignal with IEvent object. It's like:
Then IEvent is the first parameter in handler function (just like in native events). You can access the instance of the signal by IEvent.signal
I have a question for you. Why do you need to know which signal dispatched? Maybe there's a better solution for your problem.
Mike
3 Posted by PA-TH on 03 Nov, 2011 10:17 AM
Hello!
Thanks for the quick response!
Both options working great!
To pass the instance of the signal maybe is the more simple way.
But I was thinking if there is a way to avoid to pass a parameter inside signal.
So the thing that i want to do is ..
I want to map more than one signal to the same command. After in the command, i need to know which signal executed the command to make some decisions after inside the command. I know that you can pass parameters inside the signal and to inject them after in the command. But I don't feel this way super clean.
Thanks a lot,
PA-TH
4 Posted by Michal Wroblews... on 03 Nov, 2011 10:33 AM
I think it would be better to split the command into two. Each signal would have its own Command and doing its job and each would dispatch a signal calling a command doing the common thing.
Mike
5 Posted by PA-TH on 03 Nov, 2011 10:37 AM
Yes it's the most clean way.
Thanks Michal for the quick and helpful response!
PA-TH
Ondina D.F. closed this discussion on 09 Nov, 2011 02:03 PM.