question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature Request] make SelectBox inheiritable/overrideable

See original GitHub issue

chat from Discord channel

[7:04 PM] Winter: Ended up getting the SelectBox + icon working
[7:05 PM] Winter: My trick was simply to change the drawItem function in SelectBox

public GlyphLayout drawListItem(Batch batch, BitmapFont font, int index, T item, float x, float y, float width)
{
...
}
[7:05 PM] Winter: It's kinda dirty because I had to copy paste the whole SelectBox code (not heritable because of it's hidden inner class) but at least it wasn't much work

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
NathanSweetcommented, Jul 31, 2021

In my opinion the inconsistent way in which items are draw (two different drawItem functions, one in SelectBox and one in List) is much worse.

I wouldn’t call it inconsistent. One is drawing the item in the select box, the other is drawing items in the list. The select box and the list are not the same.

This problem occurs any time you build a UI control (Widget in scene2d.ui, as much as I dislike that word, couldn’t find a better one) using multiple components.

I don’t think it’s a great design to pull the details of all those components into the UI control. It bloats the API. It limits customization to only what is exposed. That leads to exposing more, which bloats the API more. Better to keep the components doing what they do separately and also customize them separately.

We can expose creation of the components so they can be customized. It makes customization a bit verbose, but otherwise it’s pretty OK.

Knowing if an actor is a descendant of a select box scroll pane (not a descendant of the select box itself) is a separate problem. We can expose the class in SelectBox since we’ll need to do so to allow customization of the scroll pane.

0reactions
terefangcommented, Jul 22, 2021

On top of that there is nothing worse in term of pattern than to have to dupplicate an entire class to do something. This creates a lot of unnecessary code and is a source of bugs if the class changes but not the dupplicated versions.

at least we can agree that copy/pasting a whole class is an anti-pattern to be avoided.

let me again play “Advocatus Diaboli” here.

@WinterAlexander maybe you should propose an implementation, on the lessons you have learn so far, from your current overriding.

@NathanSweet since you seam to have had the same experience, maybe your expertise can be merged into the proposal.

from a software engineering point of view, checking if the item implements a “SelectBoxDrawer” and hence delegate the rendering/drawing to it could be a way to move forward.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Repeat Grid overrides / inheritance (some styles differ in an ...
When I create a repeating grid, it is possible that I can change individual entries from the content. However, it is not possible...
Read more >
Cascade, specificity, and inheritance - Learn web development
An element selector is less specific; it will select all elements of that type that appear on a page, so it has less...
Read more >
How to extend / inherit components? - angular - Stack Overflow
It looks like you can inherit and override whatever you want, except for templates and styles. Some references: New features in Angular 2.3....
Read more >
List components that do not inherit from template - Forum
This query will list all settings which are currently overridden on application level (not inherited from template):. SELECT n.Caption as Node, a.
Read more >
Dictionary overrides—what they are and how to use them
Dictionary overrides are inherited by extended tables, so it may be necessary to define additional overrides to change the value of fields on ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found