How to make a centered label with Icon?


#85

What is blackColor? What is fontFQ26?

…usually what I’d do to debug this is comment attributes out to see what’s causing the issue.


#86

The issue is the background. If I remove it, then the label is drawn as specified; otherwise the Label is not visible.

Maybe the background is drawn on top of the Label?


#87

That would depend on how the background is defined… which I also can’t see.


#88
def defPinkBackground = TbtQuadBackgroundComponent.create(
texture( name:"Interface/ui-menu-button-pink.png",
        generateMips:false ),
        1f, 50, 0, 100, 68,
        0f, false);

#89

Try giving it an offset other than 0. It’s probably sitting right at the exact same Z… but still I’d expect the text to sort on top.

I think the glass style uses some Tbt quad components if you want to see some working examples.


#90

Indeed that solved my issue!

def defPinkBackground = TbtQuadBackgroundComponent.create(
texture( name:"Interface/ui-menu-button-pink.png",
        generateMips:false ),
        1f, 50, 0, 100, 68,
        1f, false);

Wait, isn’t it now on top of Label? Oh well…

Now to the next issue: Container is good for layout, but also takes over the Focus management. I’d like to use bigbanana 4-way navigation; is there a way to tell Container to not manage the focus?


#91

a) I’m pretty sure there is a way to replace the focus root behavior but I don’t remember exactly what off the top of my head. (no time to look at the moment)

b) what does 4 way navigation mean in a vertical stack of buttons?


#92

Looking forward to this one. Please post findings.

I have an issue where the container (at least I suspect that to be it) grabs focus when using arrow keys.


#93

If you don’t want any focus management at all then you can just shut it off by deactivating the function group:


#94

It does matter for table-like layout, like this:

<save slot 1>  <delete>
<save slot 2>  <delete>
<save slot 3>  <delete>
<back to main menu>

#95

Thank you. Fixed.


#97

In order to 4-way navigation to work with pre-existing component, it is necessary to add to them a Control which implements BBFocusTarget

The methods to implement are onFocusGain() and onFocusLost(). These method should update the status and the visuals of the Component so that it receive and lose focus respectively. Is there a way to do something like Button.receiveFocus()?


#98

You mean like this:


#99

Is it possible to define an alternate style for “disabled” look?


#100

:thinking::thinking::thinking:


#101

The built in GUI elements don’t really have a concept of “disabled”, I guess.

I’ve faked it before by adding a component to the element that I wanted to disable. This component was essentially a semi-transparent gray box that swallowed mouse events… offset in such a way that it was on top of the rest of the GUI element.

To be honest, if I ever add “official” support then it would probably also be something like that.


#102

I ended up with this

public class AButton extends ActionButton {

    public AButton(Action action) {
        super(action);
    }

    @Override
    public void setEnabled(boolean enabled) {
        super.setEnabled(enabled);
        ColorRGBA c = ColorRGBA.Gray;
        if (enabled) {
            c = getColor();
        }
        setColor(c);
        ((TbtQuadBackgroundComponent) getBackground()).setColor(c);
    }
}

To make it work properly, I’d need to read the color I’ve defined on the groovy. How can I do that?

Also the highlight background won’t respect this. Is there a way from groovy to reference the code written here?


#103

:banana: :banana: :banana: :slight_smile:


#104

The real issue is that enabled/disabled was not added as button actions. So probably any option you have will be a bit of a hack until that’s supported.

You can’t “read the color from groovy” but you could potentially “let groovy set it for you” by defining an actual property on AButton and marking it with the StyleAttribute annotation.

I thought about this a few different ways but I’m still not sure what you are trying to ask.

Is the button being highlighted even when it’s disabled? Is that your code doing it or mine?


#105

Button.java looks like it (correctly) won’t even call highlight on or off if the button is disabled: