[haiku-3rdparty-dev] Re: SetViewColor for BString not working :-(

  • From: Rene Gollent <anevilyak@xxxxxxxxx>
  • To: haiku-3rdparty-dev@xxxxxxxxxxxxx
  • Date: Fri, 7 Oct 2016 20:18:06 -0400

On Oct 7, 2016 19:27, "Dennis Catt" <dcatt.haiku@xxxxxxx> wrote:


I'll try to play around with it some more this weekend.  I re-ordered
some code to get around it where I don't SetViewColor to the BStringView
until after it's been added to its parent BView.  The funny part is,
that also works in the case of A4 though I figured it would and wish I'd
would have thought of that before now.


Just as a general note, for the most part it's best practice to attach a
view/control to a window before you start trying to perform much in the way
of any operations on it. The reason is twofold:

1) quite a few controls inherit settings from their parent on
AttachedToWindow(), especially since things like the various UI colors
require querying the app_server, which the view cannot do until it has a
parent window.

2) related to the last part, until the view is attached to a window, it
cannot send/receive messages, which quite a bit of other functionality also
relies upon.

I haven't checked the source for this case in particular to confirm, but
chances are what was happening is the string view was adopting its parent's
view color when added, thus overwriting the one you had manually set prior
to that.

Regards,

Rene

Other related posts: