What to return from event handler methods like View>>onLeftButtonPressed:

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

What to return from event handler methods like View>>onLeftButtonPressed:

Jochen Riekhof-6
Hi...

what is the correct type to return from an event handler method like
View>onLeftButtonPressed?
Mostly I found false or true to be returned, but I found also e.g.
0 (in Splash)
and
nil (in SlidingCardTray).

It looks like fals means "cease further processing"
but is this value really processed anywhere?

Ciao

...Jochen


Reply | Threaded
Open this post in threaded view
|

Re: What to return from event handler methods like View>>onLeftButtonPressed:

Chris Uppal-3
Jochen,

> what is the correct type to return from an event handler method like
> View>onLeftButtonPressed?
> Mostly I found false or true to be returned, but I found also e.g.
> 0 (in Splash)
> and
> nil (in SlidingCardTray).

No answer from OA yet, so here's some speculation...

The value is used (as far as I can tell) in
View>>dispatchMessage:wParam:LParam:.  The value is checked with #isInteger and
if so then that number is returned directly to Windows, otherwise (true, false,
self, nil, ...) the Windows default processing is invoked.

I once posted a bit more analysis of Dolphin's event handling in this thread.
http://groups.google.com/group/comp.lang.smalltalk.dolphin/browse_thread/thread/c40a4cba9ea1cf00/55ea44b1131c2ed0
which includes a useful MSDN link.

Adding everything together, I /think/ you should nornally return 0 if you don't
want Windows to provide its default interpretation of that event; true, false,
nil (etc) if you do want it to.

    -- chris


Reply | Threaded
Open this post in threaded view
|

Re: What to return from event handler methods like View>>onLeftButtonPressed:

Jochen Riekhof-6
Thanks Chris! Maybe OA is also issuing something. In the meantime I will
try 0 as return value to prevent further processing.

Ciao

...Jochen


Reply | Threaded
Open this post in threaded view
|

Re: What to return from event handler methods like View>>onLeftButtonPressed:

Andy Bower-3
Jochen,

> Thanks Chris! Maybe OA is also issuing something. In the meantime I
> will try 0 as return value to prevent further processing.

Yes, this will work. In general, if you want the default processing to
be called following your own then you should return nil. Otherwise, if
you don't want the default processing and the Windows message you are
overriding doesn't expect any particular result then zero is a suitable
return value.

Of course, some messages are expected to return sensible integer values
(take a look at wmCtlColor:wParam:Param: as an example) in which case
you must make sure your method answers this instead of zero.

Best Regards

--
Andy Bower
Dolphin Support
www.object-arts.com


Reply | Threaded
Open this post in threaded view
|

Re: What to return from event handler methods like View>>onLeftButtonPressed:

Jochen Riekhof-6
Hi Andy...

thanks, nice to have an official confirm on this! I still feel uneasy a
by when e.g. Splitter returns false in  onLeftButtonPressed:. Probably
because false asParameter yields 0 anyways it is the same but shouldn't
it be 0 in a strict sense?

Ciao

...Jochen


Reply | Threaded
Open this post in threaded view
|

Re: What to return from event handler methods like View>>onLeftButtonPressed:

Blair McGlashan-4
"Jochen Riekhof" <[hidden email]> wrote in message
news:[hidden email]...
> Hi Andy...
>
> thanks, nice to have an official confirm on this! I still feel uneasy a by
> when e.g. Splitter returns false in  onLeftButtonPressed:. Probably
> because false asParameter yields 0 anyways it is the same but shouldn't it
> be 0 in a strict sense?
>

The bit Chris missed is that the return value is sent asDword before it is
later tested with isInteger. #asDword is implemented on true/false to return
1/0 respectively.

Regards

Blair


Reply | Threaded
Open this post in threaded view
|

Re: What to return from event handler methods like View>>onLeftButtonPressed:

Chris Uppal-3
Blair

> The bit Chris missed is that the return value is sent asDword before it is
> later tested with isInteger.

Aha!  Yes, so it does[*].  That changes things...

Thanks for the correction.

    -- chris

([*] Cunningly hidden, though ;-)