Return As Boolean for Events - Order of Thinking

I think a return from an Event should mean “I am done”, but that doesn’t fit with reality. Sometimes a True means Done and sometimes True means Continue.
I have a difficult time remembering which one to use - True or False.
I end up looking in my code to see if I put one there.
I also look in the LR also. No matter which I cannot figure out a pattern for why some have False.
For the KeyDown event I would think True would get me the result, but it’s false.
Same thing for CancelClose.
MenuItems are generally easy since True means I’m done.
How do you remember which one to use?

No, it means I handled it. In other words: there are two MenuHandler locations:
a. in App
b. in Window(s)

If you set Return True, you said: Stop here, I have done with this Menu Handler; the other Menu Handler will not be used (fired). Return False let the Event continue…

How to know ?
The LR and this Forum

Sometimes a True means Done and sometimes True means Continue
And sometimes (MouseDown), Return True enables other Mouse Events —> Read the Docs.

And, yes, it can be confusing. Just remember you do not know and check the LR (?)

1 Like

Default return value is false, so it’s usually the one, which continues.

3 Likes

Thanks. I never could figure out how to have duplicate MenuItems in
App and the Window. That helps.

There are actually 3 layers. Control - Window - App. In all situations, return True means “this event has been handled, don’t pass it on.” Otherwise, return False or no return (same as False) means “pass the event on to the next layer of handlers.” In some cases, return True has an additional effect, such as return True from MouseDown enables MouseUp.

1 Like