Managing BMessage(s) in the scope of a BView

I was curious how to properly manage BMessage(s) in the scope of a BView. An application that I am helping with has 3 BViews and my desire is to manage BMessage(s) in each BView separately. I’ve noticed that currently only BWindow has been responding to any BMessage events fired off.

A BView is a BHandler. A BWindow is a BLooper. The looper manage messages in it’s MessageReceived.

It depends on what you are doing. If you are interested in messages from BControl/BInvoker (like a BTextControl or a BButton), you have to call SetTarget on this object. Otherwise, you have to redirect your messages to your BHandler using SendMessage from the BWindow. If you can extend a bit on what you want to do, it’d be better :slight_smile:

Barrett,

So in the application I’m working with, we have 3 BTabView(s) with each presenting a different feature for the application. I guess my thought was, insteading of managing all of the BMessage(s) in a single place like BWindow, each BView (of each BTabView) would manage its own BMessage(s) for its respective controls (BButtons, etc…). Does that make sense?

Sure. The BWindow receives the messages by default. So that’s normal you get them there. The easiest way to achieve the effect you want, is calling SetTarget on your BView like that :

https://github.com/Barrett17/Crono/blob/master/application/SettingsView.cpp#L100

Feel free to copy snippets from both SettingsView and SettingsWindow if you want.

1 Like

Thanks a bunch Barrett… I’ll take a look into this and figure it out form there.