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

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

How to remove blue focus border from TableView?

问题

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

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

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

.table-view .column-header,
.table-view .column-header .filler,
.table-view .column-header-background .filler {
    -fx-background-color: white;
    -fx-border-width: 0;
}

.table-view .column-header {
    -fx-font-size: 16px;
    -fx-border-width: 0 0 1 0;
    -fx-border-color: #efefef;
}

.table-view .column-header .label {
    -fx-alignment: center_left;
    -fx-font-size: 16pt;
    -fx-padding: 5 0 15 0;
}

.table-row-cell,
.table-row-cell:odd {
    -fx-background-color: white;
}

.table-row-cell:hover {
    -fx-background-color: #efefef;
}

.table-row-cell:selected {
    -fx-background-color: white;
    -fx-text-fill: black;
}

.table-view .table-cell {
    -fx-border-color: efefef;
    -fx-border-width: 1 0 0 0;
    -fx-font-size: 14px;
    -fx-padding: 5 3 15 3;
}

.table-view {
    -fx-border-color: white;
}

.table-view:focused .table-cell {
    -fx-text-fill: black;
}
英文:

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:

.table-view .column-header,
.table-view .column-header .filler,
.table-view .column-header-background .filler {
    -fx-background-color: white;
    -fx-border-width: 0;
}

.table-view .column-header {
    -fx-font-size: 16px;
    -fx-border-width: 0 0 1 0;
    -fx-border-color: #efefef;
}

.table-view .column-header .label {
    -fx-alignment: center_left;
    -fx-font-size: 16pt;
    -fx-padding: 5 0 15 0;
}

.table-row-cell,
.table-row-cell:odd {
    -fx-background-color: white;
}

.table-row-cell:hover {
    -fx-background-color: #efefef;
}

.table-row-cell:selected {
    -fx-background-color: white;
    -fx-text-fill: black;
}

.table-view .table-cell {
    -fx-border-color: efefef;
    -fx-border-width: 1 0 0 0;
    -fx-font-size: 14px;
    -fx-padding: 5 3 15 3;
}

.table-view {
    -fx-border-color: white;
}

.table-view:focused .table-cell {
    -fx-text-fill: black;
}

答案1

得分: 1

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

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

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.

.table-view:focus {
    outline: none;
}

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:

确定