ElementIds and Unique Id's

So first I thought that the ElementIds are much like the “id” field of an html element.
I imagined you can use it in a script like getParentWindow().findElement(titleBar.windowTitle

Is there something which does that? As I’ve learned the ElementId is rather something like html’s class, it doesn’t work like that.

Also: Why doesn’t a Component lookup it’s default ElementId in case the user-defined doesn’t exist?

I don’t understand what this means. Either the question doesn’t make any sense or the answer is “it already does?” So… you will have to be more specific.

I assume you’ve read this?

There are no unique IDs for findElement() or anything like that. You can use whatever JME methods are available for doing this kind of crappy programming. Generally, basing a lookup deep down 1000 children on some name is not a good programming practice.

I haven’t read that, I must admit. I’ve only read the first parts and tried to implement an own element.
What I did was extending Container and then I had elementId’s like Window or Window.titleBar etc which resulted to no style being applied.

So the question should say: When I define a non-existant elementId, Lemur won’t look up the style under the default Element Id? (The reason could be that you can change the style later and it’s defined in there)

So assuming I would keep those Window.titleBar namings, is there an easy way to say, that Window should copy/inherit everything from Container?

And I think I understand your concerns about naming and 1000 children, but when the hiearchy is constant as in an self-written element and the id has to be unique? I thought about it simplifing the access to GUI Components instead of having to keep a java-variable for anything.

Imagine a Script being executed by a Button Call which want’s to change it’s Windows Title.
Something like:

void onButton() {
myWindow.findElement("titleBar.windowTitle").setText("New Window Text"); // Or even:
myWindow.findElement("titleBar").findElement("windowTitle").setText("New Window Text");

The only difference between hard-coded variables is, that I know about their existance compile time (which is irrelevant for Groovy-3rdParty-Scripts)

Or would there be another good way to handle this?

What default element ID? You’ve wiped it out by specifying your own.

If you want a window title to also inherit from label… then put .label on the end… since it’s still a label.

“window.title.label” for example.

During styling, the GUI elements have no idea what their containment will be so normal CSS approaches don’t work but Lemur does support the same idea of “apply a style to all labels under foo” as long as the element IDs for those start with “foo” and end with “label”.

But I’m pretty sure that is covered in more detail than I can provide here in that link.

What is myWindow? Is it a giraffe? Is it your custom component? If it’s a giraffe or a loaded 747… then obviously calling findElement on it is nonsense. If it’s your own custom Container subclass then myWindow.getTitle() should be fine. Else if it’s just components you’ve named then just manage them better.

By the way, we have been misusing the word component in this conversation because Lemur has a very special idea of what “Component” is. We’ve so far (I think) been talking about GUI elements.

Else, if you want to use name lookups… just use JME’s-already-built-in-support-for-this… ie: just set the name of your Spatial… since all Lemur GUI elements are just Spatials. Then use getChild(“yourName”). There is no good reason for Lemur to add extra anti-pattern on top of the already provided stuff.

Sorry if I seem frustrated… I’m on vacation and typing on the laptop keyboard which makes me want to strange kittens. I hate these things with the burning fury of a thousand suns.

Note: in lieu of actual documentation on creating custom GUI elements… you can take a look at some I’ve done already in Lemur itself (especially Lemur-proto) if you want to see some ideas on how to do it.

Eventually I will get to the docs:

The public static final ELEMENT_ID. But yeah I agree, when I set something wrong it’s up to me and could be intentional.

The other things are contained in the link you’ve linked, indeed!

That’s true. I wanted to shift off thinking about a proper interface by simply exposing everything to the user :smiley:
On the other hand I don’t know if it’s that important for them to access (foreign) gui elements.

Poor Kittens! :frowning: But seriously enjoy your vacation instead of helping beginners on here :stuck_out_tongue:

Anyway, I’ve stumbled into new trouble.
I first wanted to increase the alpha-value of special containers using the groovy styles.
Problem: background is null as it’ll be evaluated afterwards (to have the parent value).
So I copied the TbtQuadBackgroundComponent.create stuff from the hub/repo but that lead me to the Problem that TbtQuadBackgroundComponent doesn’t seem to be defined, however setting fontSize and others work.

When I directly import the TbtCompo I get:

Script2.groovy: 1: unable to resolve class com.simsilica.component.TbtQuadBackgroundComponent
 @ line 1, column 1.
   import com.simsilica.component.TbtQuadBackgroundComponent;

Unfortunately I have no clue on where to look or what’s going wrong. Might this be related to the fact that my resources folder isn’t inside the src folder?
After compilation it’s build/resources/main/com/simsilica/lemur/style/base/glass-styles.groovy

And: Lemur 1.8.2

Edit: It also happens for the regular QuadBackgroundComponent, maybe the whole component sub-package is missing?

Hint: check the package name again.

Hint 2: No, seriously… wouldn’t there be a ‘lemur’ in the package name somewhere?

1 Like

Oh god that’s so embarassing :smiley: That happens when you focus too much about how many l’s there are (since on some fonts it looks like two l’s) and then forget about the lemur part :joy_cat:

The topic derails but do you have a good example for focusing? I’m planing on something like a Window Manager which always keeps track of the currently focused window and such, but I feel it’s already implemented.

Edit: I implemented FocusTarget

Edit2: Is it only implementing FocusTarget and adding a FocusManagerState? What happens with inter-elementary-focussing (i.e Textfield inside a focused Container?)

Edit3: Do you know an easy way to have a container layout be filled into the opposite y direction? I tried a BoxLayout but unfortunately there is no way to manually instanciate an Axis, so I couldn’t try if that even makes sence?

There is already a FocusManagerState. You don’t need to add one. TextFields wouldn’t work, otherwise.

I believe the focus events are delivered up the parent chain… I could be wrong as there is only about 20% implemented for focusing as per what I’ve designed.

You mean like have it grow up from the bottom? You might be able to add with negative indexes. addChild(someLabel, -1, 0) or something.

Elso, no… I guess probably not without some hacking.