Interaction implementations moved to Element? Possible?

Sort of a request and asking for help.

The periodic table of element I had done in nifty is being translated to this gui and there’s an interaction I’m doing when hovering over the elements. Problem is, there is no interaction attached to the Element class. It seems it’s not considered a control. :confused:

Since all controls literally depends (or rather extends) element I would suggest Element inherits the Control, MouseButtongListener, MouseFocusListener, KeyboardListener and TabFocusListener so if we create new controls based on Element we don’t have to implement those from scratch.

A solution I could use is take my pte and change all the Elements to buttons, but I think moving the control implementation classes should be moved to the Element class.

Thoughts and suggestions welcomed.

Oh wow… pain meds are killing my ability for basic comprehension. I read Periodic Table of Elements and then couldn’t figure out which Element was being discussed. I’m desperately trying to help here, but I’m running a bit handicapped.

IF I am following correctly, you could extend Element, add/implement the listeners and then extend your extended element, so you only have to do this once, if you have common interaction types.

If I missed the boat on this completely, please let me know… typing with one hand and half- wits (at best)

This is the pte that I did with Nifty:

I translated it to your gui, but the Element class doesn’t support interaction. ie: hover, click, etc.

Question is, wouldn’t it be better to move all basic interaction implementations to Element instead of the way it is now to each specific control?

As for you, you should be resting, not trying to drill holes into your brain. :stuck_out_tongue: But still, I’m happy to know you’re ok and visiting once in a while. :slight_smile:

I use to extend the tonegod.gui.core.Element and implement listeners to it, like:

[java]
public class StandardElement extends Element implements MouseButtonListener, MouseMoveListener {

public StandardElement(Screen screen, String UID, Vector2f position, Vector2f dimensions, Vector4f resizeBorders, String texturePath) {
    super(screen, UID, position, dimensions, resizeBorders, texturePath);
    this.setScaleNS(false);
    this.setScaleEW(false);


}

public void mouseButtonDown(int buttonIndex) {
    // Do your stuff..
}

public void mouseButtonUp(int buttonIndex) {
    // Do your stuff..
}

public void mouseMove(float deltaX, float deltaY) {
    // Do your stuff..
}

}

[/java]

then a “standard” element can be normally instantiated like any other element.
This way i can disable some default functionalities for all of my elements.

[java]
new StandardElement(screen, UID, position, dimensions, resizeBorders, texturePath)
[/java]

Yup. I know. :slight_smile:

Thing is, I prefer avoiding extending other classes if I can help it. Second thing is, I do think the basic Element class would benefit from getting the interaction classes since all controls extend this one in the first place. The exceptions I could see to this are Control and TabFocusListener since things like panels wouldn’t be appropriate for tab and it’s not really a control.

Ok. So the only way to do this yourself (not speaking of Your post as a feature request) is to grab the sources of the gui and implement those listeners in it and attach the sources as a library to your project.

https://code.google.com/p/tonegodgui/source/checkout

I do have a “contributor” tag on my name, I know how it works. But thanks nonetheless. :smiley: It’s appreciated.

Since t0neg0dGui is in pre-alpha/early alpha, it’s a suggestion to Chris that I was making.

Also, I had started to modify the sources (which I’ve had since day 1) but after reading your post I realized that it would be better until a proper response was made from Chris on that subject. But for now I agree, you are right and I should extend Element, which I already did and it’s working nicely as it should, until I get a decision from Chris. That is when she get the full use of her brain. :wink: