Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

problem with highlighting ListView Cells containing TextFlows

 
Rancher
Posts: 259
13
Eclipse IDE C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a ListView where each cell is a TextFlow, and each of those have Text objects. Some Text's are red and the others have no style so they're black.

I wanted a selected cell to show an inverse highlight: black with white text, and red to stay red.

But my Text object colors are not changing at all when a cell is selected.
any idea how to fix it?


here's the relevant part of my css.
 
S Fox
Rancher
Posts: 259
13
Eclipse IDE C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i could set the colors manually if i can get references to the actual Text objects. there must be a way to get the selected cell and then get the children of it?

i made an EventHandler for when you click on a cell, but i don't know how to get the cell itself, i can get the data of the cell:
foo = myListview.getSelectionModel().getSelectedItem(); // gives me an Entry<String, Double> and not a TextFlow full of Text objects.


 
S Fox
Rancher
Posts: 259
13
Eclipse IDE C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
this is my cell factory, the TextFlow objects are being set as a graphic.



the documentation of Cell shows an example for isSelected that changes some text colors. Cell example
but when i check this boolean in my class like they're doing, it never returns true.

i can use item.getGraphic() to give me the reference to the TextFlow that sits inside that cell if i'm able to do it like this.
i wonder if i have to create a listener to check for a selection.
 
S Fox
Rancher
Posts: 259
13
Eclipse IDE C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have discovered that isSelected() is returning true ONLY if i select a cell, then scroll the listview so that it's not able to be seen, then scroll it back to where you can see it again. this is ridiculous.
 
Sheriff
Posts: 7111
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

S Fox wrote:i could set the colors manually if i can get references to the actual Text objects. there must be a way to get the selected cell and then get the children of it?

i made an EventHandler for when you click on a cell, but i don't know how to get the cell itself, i can get the data of the cell:
foo = myListview.getSelectionModel().getSelectedItem(); // gives me an Entry<String, Double> and not a TextFlow full of Text objects.


The method should be getSelectedItems and it should return an ObservableList which you can loop through.
 
Knute Snortum
Sheriff
Posts: 7111
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

S Fox wrote:this is my cell factory, the TextFlow objects are being set as a graphic.



the documentation of Cell shows an example for isSelected that changes some text colors. Cell example
but when i check this boolean in my class like they're doing, it never returns true.

i can use item.getGraphic() to give me the reference to the TextFlow that sits inside that cell if i'm able to do it like this.
i wonder if i have to create a listener to check for a selection.


Is it possible that updateItemSelection needs to be called before setGraphic?
 
My first bit of advice is that if you are going to be a mime, you shouldn't talk. Even the tiny ad is nodding:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic