如何从TableView中删除蓝色焦点边框?

huangapple go评论110阅读模式
英文:

How to remove blue focus border from TableView?

问题

我正在为一个TableView设置样式。我将边框颜色设置为白色(与背景颜色相同),以使其不可见。但是,当表格获得焦点时,边框变为蓝色。我尝试添加table-view:focused { -fx-border-color: white; }来修复它,但没有帮助。我该如何修复这个问题?

我没有添加截图,因为当我按下Print Screen键时,表格会失去焦点。

以下是我的完整样式表,如果相关的话:

  1. .table-view .column-header,
  2. .table-view .column-header .filler,
  3. .table-view .column-header-background .filler {
  4. -fx-background-color: white;
  5. -fx-border-width: 0;
  6. }
  7. .table-view .column-header {
  8. -fx-font-size: 16px;
  9. -fx-border-width: 0 0 1 0;
  10. -fx-border-color: #efefef;
  11. }
  12. .table-view .column-header .label {
  13. -fx-alignment: center_left;
  14. -fx-font-size: 16pt;
  15. -fx-padding: 5 0 15 0;
  16. }
  17. .table-row-cell,
  18. .table-row-cell:odd {
  19. -fx-background-color: white;
  20. }
  21. .table-row-cell:hover {
  22. -fx-background-color: #efefef;
  23. }
  24. .table-row-cell:selected {
  25. -fx-background-color: white;
  26. -fx-text-fill: black;
  27. }
  28. .table-view .table-cell {
  29. -fx-border-color: efefef;
  30. -fx-border-width: 1 0 0 0;
  31. -fx-font-size: 14px;
  32. -fx-padding: 5 3 15 3;
  33. }
  34. .table-view {
  35. -fx-border-color: white;
  36. }
  37. .table-view:focused .table-cell {
  38. -fx-text-fill: black;
  39. }
英文:

I'm styling a TableView. I set the border color to white (same as background color) so it is invisible. However, when the table is focused, the border becomes blue. I tried adding table-view:focused { -fx-border-color: white; } to fix it, but it didn't help. How do I fix this?

I didn't add a screenshot because when I hit Print Screen the Table loses focus.

Below is my full stylesheet, if it's relevant:

  1. .table-view .column-header,
  2. .table-view .column-header .filler,
  3. .table-view .column-header-background .filler {
  4. -fx-background-color: white;
  5. -fx-border-width: 0;
  6. }
  7. .table-view .column-header {
  8. -fx-font-size: 16px;
  9. -fx-border-width: 0 0 1 0;
  10. -fx-border-color: #efefef;
  11. }
  12. .table-view .column-header .label {
  13. -fx-alignment: center_left;
  14. -fx-font-size: 16pt;
  15. -fx-padding: 5 0 15 0;
  16. }
  17. .table-row-cell,
  18. .table-row-cell:odd {
  19. -fx-background-color: white;
  20. }
  21. .table-row-cell:hover {
  22. -fx-background-color: #efefef;
  23. }
  24. .table-row-cell:selected {
  25. -fx-background-color: white;
  26. -fx-text-fill: black;
  27. }
  28. .table-view .table-cell {
  29. -fx-border-color: efefef;
  30. -fx-border-width: 1 0 0 0;
  31. -fx-font-size: 14px;
  32. -fx-padding: 5 3 15 3;
  33. }
  34. .table-view {
  35. -fx-border-color: white;
  36. }
  37. .table-view:focused .table-cell {
  38. -fx-text-fill: black;
  39. }

答案1

得分: 1

应该移除添加到表格的蓝色边框,如果您使用了outline CSS属性并将其设置为none。
因此,当表格处于焦点状态时,请将outline设置为none。

  1. .table-view:focus {
  2. outline: none;
  3. }
英文:

the blue border added to your table should be removed if you use the outline css property and set it to none.
So , here set the outline : none for your table when focused.

  1. .table-view:focus {
  2. outline: none;
  3. }

huangapple
  • 本文由 发表于 2020年8月2日 19:45:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/63215599.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定