[haiku-development] Re: Handling mouse events with multiple BViews

  • From: "Axel Dörfler" <axeld@xxxxxxxxxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Mon, 09 Jun 2008 08:56:10 +0200 CEST

James Kim <jkim202@xxxxxxxxxxxxxxxxx> wrote:
> > I am having trouble detecting mouse clicks in BView. A 
> > BViewSubclass
> > which is drawn inside some BWindow is implementing MouseDown() 
> > method
> > but it won't respond to mouse clicks. The reason is that BWindow
> > contains other BViews covering the entire BViewSubclass. How do you 
> > make
> > it so that all mouse clicks invoke BViewSubclass' MouseDown() 
> > method?
> > Maybe move BViewSubclass to top layer or something like that?
> Ah.. I think I just got it.. I used BView::MakeFocus() in 
> BViewSubclass.
> Sorry for that. Thanks anyway.

In general, it doesn't sound like a good idea to have views that covers 
other views unless they are in a parent-child relation. It's actually 
forbidded and has undefined outcome if you do otherwise.
Using MakeFocus() should only ever be needed to receive keyboard 
events, never for mouse events - this shows that you indeed use the 
view hierarchy incorrectly.

Bye,
   Axel.


Other related posts: