简体   繁体   中英

How to DISABLE transparency for TextView in GTK#?

I am making a GTK# application and I have some weird behavior with TextView (or perhaps ScrolledWindow, can't really tell):

问题

It's basically copying whatever's behind it and using it as the background, when the background should be a solid color. When I switch tabs, it even displays what was in the previously selected tab.

How do I fix this behavior?

Well, I didn't like that I had to do it this way, but it works:

    // Fix the weird display bug
    drawnHandler = new DrawnHandler((o, args) =>
    {
        this.Drawn -= drawnHandler;
        var color = ConsoleBox.StyleContext.GetBackgroundColor(StateFlags.Normal);
        ConsoleBox.OverrideBackgroundColor(StateFlags.Normal, new Gdk.RGBA()
        {
            Red = color.Red,
            Green = color.Green,
            Blue = color.Blue,
            Alpha = 1
        });
    });
    this.Drawn += drawnHandler;

This gets the proper background color and sets it without alpha (which I'm not even sure how the alpha was set in the first place since I never changed the background color anywhere in the code).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM