[haiku-development] BView with messages

  • From: Caitlin Shaw <rogueeve@xxxxxxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Sun, 27 Sep 2009 13:29:38 -0700


Yup, I have something to say about BViews again :). Anyway one of the things I have found lacking in the Be API (although it makes sense) is that BViews cannot receive messages. This is annoying when you have, for example, a class derived from BView which is supposed to be a drop-in component, and that class creates it's own controls etc within it's frame.

Be controls by default send their invocation messages to the owning window, which means you have to either ping-pong the messages off the window's MessageReceived (breaks encapsulation), or have the view spawn it's own BLooper (a bit more extra clutter).

So I put together this little class, "MessageView". It works exactly like BView, except that it provides a MessageReceived function which you can override. It also provides two functions "Looper()" and "Messenger()" which return a pointer to a looper and a messenger that can be used to send messages which will show up in the view's MessageReceived. All you do is tell your controls "control->SetTarget(Looper())".

Is there something like this already? If not maybe someone will find it useful. You can get it from
http://five75.sourceforge.net/files/MessageView.zip


Other related posts: