[haiku-development] Re: Mouse Event

  • From: <philippe.houdoin@xxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Tue, 1 Jul 2008 04:43:25 +0200

Hi Mohmed,

> How do I capture mouse events (mouse down, mouse up, mouse leave etc.)
> inside the Desktop class?

If you're looking on regular way to track mouse in your BViews, you will find 
everything and more in this BeNewsletter article by Owen Smith of the old good 
days, "Developers' Workshop: The Bitchin' Async"

It's online here:
http://www.haiku-os.org/legacy-docs/benewsletter/Issue3-46.html

For a simple and sample usage code, you can look at several place in Haiku code 
source tree. For instance:
src/apps/pulse/CPUButton.cpp

To track mouse events outside your view (aka everywhere over "desktop", the 
trick is to use SetEventMask(B_POINTER_EVENTS), not 
SetMouseEventMask(B_POINTER_EVENTS), so your Mouse* hooks will be called even 
when the mouse will be outside your view.

Check those two BView methods documentation for details:
http://www.haiku-os.org/legacy-docs/bebook/BView.html#BView_SetEventMask

Hope this help.

Bye,
  Philippe.



Other related posts: